rand

package standard library
go1.26.11 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0 modules, 0 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

Index

Constants

This section is empty.

Variables

View Source
var Reader io.Reader = reader{}

Reader is an io.Reader that calls drbg.Read.

It should be used internally instead of crypto/rand.Reader, because the latter can be set by applications outside of tests. These applications then risk breaking between Go releases, if the way the Reader is used changes.

Functions

func CustomReader

func CustomReader(r io.Reader) io.Reader

CustomReader returns Reader or, only if the GODEBUG setting "cryptocustomrand=1" is set, the provided io.Reader.

If returning a non-default Reader, it calls randutil.MaybeReadByte on it.

func IsDefaultReader

func IsDefaultReader(r io.Reader) bool

IsDefaultReader reports whether r is the default crypto/rand.Reader.

If true, the Read method of r can be assumed to call drbg.Read.

func SetTestingReader

func SetTestingReader(r io.Reader)

SetTestingReader overrides all calls to drbg.Read. The Read method of r must never return an error or return short.

SetTestingReader panics when building against Go Cryptographic Module v1.0.0.

SetTestingReader is pulled by testing/cryptotest.setGlobalRandom via go:linkname.

Types

This section is empty.

Jump to

Keyboard shortcuts

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