randutil

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 5 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int64n added in v0.47.0

func Int64n(n uint) int64

func Intn added in v0.47.0

func Intn(n uint) int

Intn returns a random number backed by `crypto/rand`.

func NewSeedInt64Crypto added in v0.41.0

func NewSeedInt64Crypto() (int64, error)

NewSeedInt64Crypto creates an `int64` seed value for `math/rand`. This is preferred over `NewSeedInt64Time()`. See: https://stackoverflow.com/a/54491783/1908967

func NewSeedInt64Time added in v0.41.0

func NewSeedInt64Time() int64

NewSeedInt64Time creates an `int64` seed value for `math/rand` based on `time.Now()`. This can have reduced entropy if used constantly throughout with shourl time differentials. See: https://stackoverflow.com/a/12321192/1908967

func RandString added in v0.44.0

func RandString(alphabet string, length uint) string

RandString returns a random string of length `length` using the supplied alphabet. If no alphabet is provided, `AlphabetBase16`, aha hexadecimal is used.

Types

type CryptoRandSource added in v0.47.0

type CryptoRandSource struct{}

CryptoRandSource is a `crypto/rand` backed source that satisfies the `math/rand.Source` interface definition. It can be used as `r := rand.New(NewCryptoRandSource())` See: https://stackoverflow.com/a/35208651/1908967

func NewCryptoRandSource added in v0.47.0

func NewCryptoRandSource() CryptoRandSource

func (CryptoRandSource) Int63 added in v0.47.0

func (CryptoRandSource) Int63() int64

func (CryptoRandSource) Seed added in v0.47.0

func (CryptoRandSource) Seed(int64)

Jump to

Keyboard shortcuts

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