rand

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Reader io.Reader //nolint:gochecknoglobals

Reader provides a random reader that can reset during testing.

Functions

func CryptoRandomBytes

func CryptoRandomBytes(max int) ([]byte, error)

func RandomBytes

func RandomBytes(r io.Reader, n int) ([]byte, error)

RandomBytes returns a slice with random bytes from an io.Reader source.

Types

type DefaultRandomGenerator

type DefaultRandomGenerator struct{}

DefaultRandomGenerator uses crypto/rand.Reader to generate random bytes.

func (DefaultRandomGenerator) CryptoRandomBytes

func (g DefaultRandomGenerator) CryptoRandomBytes(max int) ([]byte, error)

CryptoRandomBytes generates random bytes using the crypto/rand package.

type RandomGenerator

type RandomGenerator interface {
	CryptoRandomBytes(max int) ([]byte, error)
}
var CryptoRandGen RandomGenerator = DefaultRandomGenerator{} //nolint:gochecknoglobals

CryptoRandGen provides RandomGenerator interface that can reset during testing.

Jump to

Keyboard shortcuts

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