Documentation
¶
Overview ¶
Package rand provides cryptographically secure, high-performance random string and byte generation.
Index ¶
Constants ¶
View Source
const ( Digits = "0123456789" Lowercase = "abcdefghijklmnopqrstuvwxyz" Uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Symbols = "!@#$%^&*-_=+" )
Variables ¶
This section is empty.
Functions ¶
func RandomBytes ¶ added in v0.3.18
RandomBytes generates n cryptographically secure random bytes using the default alphanumeric character set.
func RandomString ¶ added in v0.3.18
RandomString generates a cryptographically secure random string of length n using the default alphanumeric character set.
Types ¶
type Generator ¶ added in v0.3.18
type Generator interface { // RandBytes generates a random byte slice of the specified size using the generator's character set. RandBytes(size int) ([]byte, error) // RandString generates a random string of the specified size using the generator's character set. RandString(size int) (string, error) // Read populates the given byte slice with random bytes from the generator's character set. // It implements the io.Reader interface. Read(p []byte) (n int, err error) }
Generator defines the interface for generating cryptographically secure random data.
func CustomRand ¶
CustomRand creates a new random data generator with a custom character set. It returns the RandGenerator interface.
type Kind ¶
type Kind int
Kind defines the character set to be used for random string generation.
const ( KindDigit Kind = 1 << iota // KindDigit represents digit characters (0-9). KindLowerCase Kind = 1 << iota // KindLowerCase represents lowercase letters (a-z). KindUpperCase Kind = 1 << iota // KindUpperCase represents uppercase letters (A-Z). KindSymbol Kind = 1 << iota // KindSymbol represents common symbol characters. KindAlphanumeric = KindDigit | KindLowerCase | KindUpperCase // KindAlphanumeric represents a combination of digits, lowercase, and uppercase letters. KindAllWithSymbols = KindAlphanumeric | KindSymbol // KindAllWithSymbols represents a combination of digits, lowercase, uppercase letters, and symbols. )
Click to show internal directories.
Click to hide internal directories.