rand

package
v0.0.0-...-fd92830 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2017 License: BSD-3-Clause Imports: 5 Imported by: 0

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

View Source
var Reader io.Reader = reader

Functions

func Read

func Read(buf []byte) (n int, err error)

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

func SetNumRoutines(num int) int

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL