Documentation ¶
Overview ¶
Cryptographically secure pseudorandom numbers.
This package uses the Linux kernel's
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( GRND_NONBLOCK = 0x1 GRND_RANDOM = 0x2 GRND_INSECURE = 0x4 )
Flags for Getrandom()
var (
ErrInvalidSize = errors.New("invalid size")
)
Functions ¶
func Bytes ¶
Bytes returns n number cryptographically secure random bytes from /dev/random. This function panics if size <= 0 or failed to get random bytes.
func Getrandom ¶
Getrandom obtains a series of random bytes by filling buffer buf.
By default Getrandom() blocks if no random bytes are available. If the GRND_NONBLOCK flag is set, then Getrandom() does not block in these cases, but instead immediately returns unix.EAGAIN.
If GRND_RANDOM bit is set, then random bytes are drawn from the random source (i.e., the same source as the /dev/random device) instead of the urandom source.
The GRND_INSECURE bit is removes the blocking and allow returning potentially "insecure" random bytes.
See more: man random(4) and random(7)
Types ¶
This section is empty.