Documentation ¶
Overview ¶
Package rand implements a pseudo-random number generator (PRNG).
This was designed to be a faster alternative to the built-in /dev/urandom device built into most Linux kernels. This PRNG is based on the Advanced Encryption Standard (AES) cipher operating in cipher-block chaining (CBC) mode. Some initial data is continually encrypted over and over and should provide pseudo-random data of cryptographic quality.
This implementation can generate data significantly faster than /dev/urandom by running generator routines in parallel. By default, this library only operates using one routine, but the number of routines can be set using the SetNumRoutines function. The reference command-line implementation sets the number of routines to be equal to the number of cores available.
High-end processors are starting to support the AES-NI instruction set that can vastly improve AES encoding rates. The underlying Go library does take advantage of these instructions if available. In that situation, this library is likely to be more memory-throughput bound than CPU bound. Other than each generator occupying about 1MB of memory, this should not lead to noticeable degradation of performance since generators will block if their outputs are not consumed fast enough.
The author does not take responsibility for any damages potentially caused if the data generated by this library is not actually cryptographically-secure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Reader io.Reader = reader
Functions ¶
func Read ¶
Read is a helper function that calls Reader.Read using io.ReadFull. On return, n == len(b) if and only if err == nil.
func SetNumRoutines ¶
Sets the number of routines that will generate pseudo-random data and returns the previous setting. If n < 1, it does not change the current setting. By default, the number of routines starts off at 1.
Types ¶
This section is empty.