Documentation ¶
Overview ¶
Package xrand provides helper functions for generating random numbers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
Bytes returns an amount of cryptographically-secure random bytes equal to the the specified size.
The bytes are generated using the crypto/rand package and will panic if crypto/rand fails to generate the requested amount of bytes.
Defaults to 32 if no size is specified.
func BytesWithReader ¶
BytesWithReader is like Bytes, but allows you to specify your own reader.
func Int63 ¶
func Int63() int64
Int63 returns a non-negative cryptographically-secure random 63-bit integer as an int64. It panics if crypto/rand fails to generate random bytes.
func IntChaChaCha ¶
IntChaChaCha returns a cryptographically secure random integer in the range [0, n) using the ChaCha20 stream cipher. If the provided io.Reader is nil, it defaults to using crypto/rand.Reader.
func NewSource64 ¶
NewSource64 returns a new cryptographically secure random number generator that satisfies the math/rand.Source64 interface.
Types ¶
type Source64 ¶
type Source64 struct { // Stream is the underlying AES-256 CTR stream. cipher.Stream // contains filtered or unexported fields }
Source64 implements the math/rand.Source64 interface as a cryptographically secure random number generator using AES-256 in CTR mode.