Documentation ¶
Index ¶
- func CryptoUint64() (uint64, error)
- func GenerateCryptoRandomString(n int, runes string) (string, error)
- func GenerateReaderCryptoRandomString(n int, runes string, reader io.Reader) (string, error)
- func ReaderCryptoUint64(reader io.Reader) (uint64, error)
- type MathRandomGenerator
- type ReaderMathRandomGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CryptoUint64 ¶
CryptoUint64 returns cryptographic random uint64.
func GenerateCryptoRandomString ¶
GenerateCryptoRandomString generates a random string for cryptographic usage.
func GenerateReaderCryptoRandomString ¶
GenerateReaderCryptoRandomString generates a reader-based random string for cryptographic usage.
Types ¶
type MathRandomGenerator ¶
type MathRandomGenerator interface { // Intn returns random integer within [0:n). Intn(n int) int // Uint32 returns random 32-bit unsigned integer. Uint32() uint32 // Uint64 returns random 64-bit unsigned integer. Uint64() uint64 // GenerateString returns ranom string using given set of runes. // It can be used for generating unique ID to avoid name collision. // // Caution: DO NOT use this for cryptographic usage. GenerateString(n int, runes string) string }
MathRandomGenerator is a random generator for non-crypto usage.
func NewMathRandomGenerator ¶
func NewMathRandomGenerator() MathRandomGenerator
NewMathRandomGenerator creates new mathmatical random generator. Random generator is seeded by crypto random.
func NewReaderMathRandomGenerator ¶
func NewReaderMathRandomGenerator(reader io.Reader) MathRandomGenerator
NewMathRandomGenerator creates new mathmatical random generator. Random generator is seeded by crypto random.
type ReaderMathRandomGenerator ¶
type ReaderMathRandomGenerator interface { // Intn returns random integer within [0:n). Intn(n int) int // Uint32 returns random 32-bit unsigned integer. Uint32() uint32 // Uint64 returns random 64-bit unsigned integer. Uint64() uint64 // GenerateString returns ranom string using given set of runes. // It can be used for generating unique ID to avoid name collision. // // Caution: DO NOT use this for cryptographic usage. GenerateString(n int, runes string) string }
MathRandomGenerator is a random generator for non-crypto usage.
Click to show internal directories.
Click to hide internal directories.