Documentation ¶
Overview ¶
Package randx contains randomization functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SecureString ¶ added in v0.1.6
SecureString returns a string of length n, composed of random characters from the provided alphabet, generated from a secure RNG. If the input slice is nil, returns a random mixed case alphanumeric string.
Types ¶
type Rand ¶
type Rand interface { StringRand Int() int Intn(n int) int Int31() int32 Int31n(n int32) int32 Int63() int64 Int63n(n int64) int64 Float32() float32 Float64() float64 Read(p []byte) (n int, err error) }
Rand can generate random values of various types.
type StringRand ¶ added in v0.1.6
StringRand can generate random strings for an alphabet. Supports both math/rand and crypto/rand.
var (
SecureStringRand StringRand = NewSecureStringRand(cryptrand.Reader)
)
SecureStringRand is a StringRand that uses a secure RNG.
func NewSecureStringRand ¶ added in v0.1.6
func NewSecureStringRand(r io.Reader) StringRand
NewSecureStringRand returns a StringRand that uses a secure RNG.
Click to show internal directories.
Click to hide internal directories.