randutil

package
v0.41.8 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CryptoRandInt64 added in v0.38.5

func CryptoRandInt64(random io.Reader, max int64) (int64, error)

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

Types

type CryptoRand

type CryptoRand struct {
	// contains filtered or unexported fields
}

func NewCryptoRand

func NewCryptoRand(r io.Reader, s mrand.Source) CryptoRand

func (*CryptoRand) Int64n

func (cr *CryptoRand) Int64n(n int64) (int64, error)

func (*CryptoRand) Intn

func (cr *CryptoRand) Intn(n int) (int, error)

func (*CryptoRand) MustInt64n

func (cr *CryptoRand) MustInt64n(n int64) int64

func (*CryptoRand) MustIntn

func (cr *CryptoRand) MustIntn(n int) int

Jump to

Keyboard shortcuts

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