Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SingleThreadedGenerator ¶
type SingleThreadedGenerator interface { // Generates a number in range [0.0, 1.0). Float64() float64 // Generates a number in range [0, n), where n is of type int64. Int64N(n int64) int64 // Generates a number in range [0, n), where n is of type int. IntN(n int) int // Generates arbitrary bytes of data. This method is guaranteed // to succeed. Read(p []byte) (int, error) // Shuffle the elements in a list. Shuffle(n int, swap func(i, j int)) // Generates an arbitrary 32-bit integer value. Uint32() uint32 // Generates an arbitrary 64-bit integer value. Uint64() uint64 }
SingleThreadedGenerator is a Random Number Generator (RNG) that cannot be used concurrently. This interface is a subset of Go's rand.Rand.
func NewFastSingleThreadedGenerator ¶
func NewFastSingleThreadedGenerator() SingleThreadedGenerator
NewFastSingleThreadedGenerator creates a new SingleThreadedGenerator that is not suitable for cryptographic purposes. The generator is randomly seeded.
type ThreadSafeGenerator ¶
type ThreadSafeGenerator interface { SingleThreadedGenerator IsThreadSafe() }
ThreadSafeGenerator is identical to SingleThreadedGenerator, except that it is safe to use from within multiple goroutines without additional locking. These generators may be slower than their single-threaded counterparts.
var CryptoThreadSafeGenerator ThreadSafeGenerator = cryptoThreadSafeGenerator{ Rand: math_rand.New(cryptoSource{}), }
CryptoThreadSafeGenerator is an instance of ThreadSafeGenerator that is suitable for cryptographic purposes.
var FastThreadSafeGenerator ThreadSafeGenerator = fastThreadSafeGenerator{}
FastThreadSafeGenerator is an instance of ThreadSafeGenerator that is not suitable for cryptographic purposes. The generator is randomly seeded on startup.