randutil

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
const (
	AlphabetBase10 = "0123456789"
	AlphabetBase16 = "0123456789abcdef"
	AlphabetBase36 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	AlphabetBase62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
)

Variables

This section is empty.

Functions

func CryptoRandInt64 added in v0.38.5

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

func MustRandString added in v0.44.0

func MustRandString(alphabet string, length uint) string

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, error)

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