random

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MPL-2.0 Imports: 7 Imported by: 28 modules, 53 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package random provides facilities for generating random or pseudorandom cryptographic objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bits

func Bits(bitlen uint, exact bool, rand cipher.Stream) []byte

Bits chooses a uniform random BigInt with a given maximum BitLen. If 'exact' is true, choose a BigInt with _exactly_ that BitLen, not less

func Bytes

func Bytes(b []byte, rand cipher.Stream)

Bytes fills a slice with random bytes from rand.

func Int

func Int(mod *big.Int, rand cipher.Stream) *big.Int

Int chooses a uniform random big.Int less than a given modulus

func New

func New(readers ...io.Reader) cipher.Stream

New returns a new cipher.Stream that gets random data from the given readers. If no reader was provided, Go's crypto/rand package is used. Otherwise, for each source, 32 bytes are read. They are concatenated and then hashed, and the resulting hash is used as a seed to a PRNG. The resulting cipher.Stream can be used in multiple threads.

Types

This section is empty.

Jump to

Keyboard shortcuts

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