fastrand

package module
v0.0.0-...-6fb6489 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: MIT Imports: 9 Imported by: 0

README

fastrand

This repository has moved to GitLab.

Documentation

Overview

Package fastrand implements a cryptographically secure pseudorandom number generator. The generator is seeded using the system's default entropy source, and thereafter produces random values via repeated hashing. As a result, fastrand can generate randomness much faster than crypto/rand, and generation cannot fail beyond a potential panic at init.

The method used in this package is similar to the Fortuna algorithm, which is used in used in FreeBSD for /dev/urandom. This package uses techniques that are known to be secure, however the exact implementation has not been heavily reviewed by cryptographers.

Index

Constants

This section is empty.

Variables

View Source
var Reader io.Reader

Reader is a global, shared instance of a cryptographically strong pseudo- random generator. It uses blake2b as its hashing function. Reader is safe for concurrent use by multiple goroutines.

Functions

func BigIntn

func BigIntn(n *big.Int) *big.Int

BigIntn returns a uniform random *big.Int in [0,n). It panics if n <= 0.

func Bytes

func Bytes(n int) []byte

Bytes is a helper function that returns n bytes of random data.

func Intn

func Intn(n int) int

Intn returns a uniform random int in [0,n). It panics if n <= 0.

func Perm

func Perm(n int) []int

Perm returns a random permutation of the integers [0,n).

func Read

func Read(b []byte)

Read is a helper function that calls Reader.Read on b. It always fills b completely.

func Uint64n

func Uint64n(n uint64) uint64

Uint64n returns a uniform random uint64 in [0,n). It panics if n == 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

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