rand

package
v0.0.0-...-93bbcbf Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0, MIT Imports: 7 Imported by: 13

Documentation

Overview

Package rand implements a cryptographically secure pseudorandom number generator.

Index

Constants

This section is empty.

Variables

View Source
var Reader io.Reader = &bufferedReader{r: bufio.NewReader(&reader{})}

Reader is the default reader.

Functions

func Init

func Init() error

Init can be called to make sure /dev/urandom is pre-opened on kernels that do not support getrandom(2).

func Int63

func Int63() int64

Int63 is analogous to the standard library's math/rand.Int63.

func Int63n

func Int63n(n int64) int64

Int63n is analogous to the standard library's math/rand.Int63n.

func Read

func Read(b []byte) (int, error)

Read reads from the default reader.

func Uint32

func Uint32() uint32

Uint32 is analogous to the standard library's math/rand.Uint32.

func Uint64

func Uint64() uint64

Uint64 is analogous to the standard library's math/rand.Uint64.

Types

type RNG

type RNG struct {
	Reader io.Reader
}

RNG exposes convenience functions based on a cryptographically secure io.Reader.

func RNGFrom

func RNGFrom(r io.Reader) RNG

RNGFrom returns a new RNG. r must be a cryptographically secure io.Reader.

func (*RNG) Int63

func (rg *RNG) Int63() int64

Int63 is analogous to the standard library's math/rand.Int63.

func (*RNG) Int63n

func (rg *RNG) Int63n(n int64) int64

Int63n is analogous to the standard library's math/rand.Int63n.

func (*RNG) Uint16

func (rg *RNG) Uint16() uint16

Uint16 is analogous to the standard library's math/rand.Uint16.

func (*RNG) Uint32

func (rg *RNG) Uint32() uint32

Uint32 is analogous to the standard library's math/rand.Uint32.

func (*RNG) Uint64

func (rg *RNG) Uint64() uint64

Uint64 is analogous to the standard library's math/rand.Uint64.

Jump to

Keyboard shortcuts

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