rand

package
v0.8.14 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(n int) []byte

Bytes returns n random bytes generated from math/rand's global default Source.

func NewRand

func NewRand() *mrand.Rand

NewRand returns a prng, that is seeded with OS randomness. The OS randomness is obtained from crypto/rand, however, like with any math/rand.Rand object none of the provided methods are suitable for cryptographic usage.

Note that the returned instance of math/rand's Rand is not suitable for concurrent use by multiple goroutines.

For concurrent use, call Reseed to reseed math/rand's default source and use math/rand's top-level convenience functions instead.

func Reseed

func Reseed()

Reseed conveniently re-seeds the default Source of math/rand with randomness obtained from crypto/rand.

Note that this does not make math/rand suitable for cryptographic usage.

Use math/rand's top-level convenience functions remain suitable for concurrent use by multiple goroutines.

func Str

func Str(length int) string

Str constructs a random alphanumeric string of given length from math/rand's global default Source.

Types

This section is empty.

Jump to

Keyboard shortcuts

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