randstr

package
v0.0.0-...-c971ce2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2021 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package randstr generates random strings (e.g. passwords), supporting unicode and emojis.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Runes

func Runes(rand io.Reader, charset charset.Charset, length int) ([]rune, error)

Runes returns a random array of runes, using only the runes given and the io.Reader as the source of randomness. For cryptographic randomness use crypto/rand's Reader.

func String

func String(rand io.Reader, charset charset.Charset, length int) (string, error)

String returns a random string of length, using only the runes given and the io.Reader as the source of randomness. For cryptographic randomness use crypto/rand's Reader.

Example
package main

import (
	"crypto/rand"

	"4d63.com/randstr/lib/charset"
	"4d63.com/randstr/lib/randstr"
)

func main() {
	_, _ = randstr.String(rand.Reader, charset.ASCII, 50)
}
Output:

func Write

func Write(w runes.Writer, rand io.Reader, charset charset.Charset, length int) error

Write writes to the writer random runes (as bytes), using only the runes given and the io.Reader as the source of randomness. For cryptographic randomness use crypto/rand's Reader.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL