rand

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package rand combines crypto.rand and math.rand for more secure random number generation with reduced performance impact. The package keeps a pool of math generators, making it unlikely that two consecutive random numbers are generated by the same math generator. In addition, it reseeds the math generators periodically using a seed generated by a crypto generator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlphaNum32

func AlphaNum32(length int) string

AlphaNum32 generates a random string of the specified length. The string will include only uppercase letters and numbers A-V, 0-9.

func AlphaNum64

func AlphaNum64(length int) string

AlphaNum64 generates a random string of the specified length. The string will include only alphanumeric characters a-z, A-Z, 0-9.

func Intn

func Intn(n int) int

Intn generates a random number in the range [0,n).

func New

func New() *mathrand.Rand

New creates a new math random generator seeded by a crypto random number.

func Read

func Read(p []byte) (n int, err error)

Read generates len(p) random bytes and writes them into p. It always returns len(p) and a nil error.

Types

type Void

type Void any

Void is an empty type.

Jump to

Keyboard shortcuts

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