...

#
Package rand

Package rand implements a cryptographically secure
pseudorandom number generator.

In the call graph viewer below, each node
is a function belonging to this package
and its children are the functions it
calls—perhaps dynamically.

The root nodes are the entry points of the
package: functions that may be called from
outside the package.
There may be non-exported or anonymous
functions among them if they are called
dynamically from another package.

Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring `func`

token.

Functions may be omitted if they were
determined to be unreachable in the
particular programs or tests that were
analyzed.

## Variables

Reader is a global, shared instance of a cryptographically
strong pseudo-random generator.

On Linux, Reader uses getrandom(2) if available, /dev/urandom otherwise.
On OpenBSD, Reader uses getentropy(2).
On other Unix-like systems, Reader reads from /dev/urandom.
On Windows systems, Reader uses the CryptGenRandom API.

var Reader io.Reader

func Int(rand io.Reader, max *big.Int) (n *big.Int, err error)

Int returns a uniform random value in [0, max). It panics if max <= 0.

func Prime(rand io.Reader, bits int) (p *big.Int, err error)

Prime returns a number, p, of the given size, such that p is prime
with high probability.
Prime will return error for any error returned by rand.Read or if bits < 2.

func Read(b []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.

▾ Example

This example reads 10 cryptographically secure pseudorandom numbers from
rand.Reader and writes them to a byte slice.