Documentation ¶
Overview ¶
package rand_ Creating Random Strings in Go
Index ¶
- Constants
- func Bytes(n int) []byte
- func BytesCrypto(n int) ([]byte, error)
- func BytesMath(n int) []byte
- func String(len int) string
- func StringCrypto(length int64) (string, error)
- func StringCryptoWithCharset(length int64, charset string) (string, error)
- func StringMath(length int) string
- func StringMathWithCharset(length int, charset string) string
- func StringWithCharset(len int, charset string) string
Constants ¶
const ( CharsetBinaryDigits = "01" CharsetOctalDigits = "01234567" CharsetDecimalDigits = "0123456789" CharsetHexadecimalDigits = "0123456789aAbBcCdDeEfF" CharsetSign = "+-" CharsetPeriod = "." CharsetExponent = "eEp" CharsetAlpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" CharsetAlphaNum = CharsetDecimalDigits + CharsetAlpha CharsetBase64 = CharsetAlphaNum + "+/" // StdEncoding is the standard base64 encoding, as defined in // RFC 4648. CharsetBase64StdEncoding = CharsetBase64RawStdEncoding + string(base64.StdPadding) // URLEncoding is the alternate base64 encoding defined in RFC 4648. // It is typically used in URLs and file names. CharsetBase64URLEncoding = CharsetBase64RawURLEncoding + string(base64.StdPadding) // RawStdEncoding is the standard raw, unpadded base64 encoding, // as defined in RFC 4648 section 3.2. // This is the same as StdEncoding but omits padding characters. CharsetBase64RawStdEncoding = CharsetAlphaNum + "+/" // RawURLEncoding is the unpadded alternate base64 encoding defined in RFC 4648. // It is typically used in URLs and file names. // This is the same as URLEncoding but omits padding characters. CharsetBase64RawURLEncoding = CharsetAlphaNum + "-_" )
Numerical elements
Variables ¶
This section is empty.
Functions ¶
func BytesCrypto ¶
BytesCrypto returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func BytesMath ¶
BytesCrypto returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func String ¶
only take in a length, and will use a default characters set to generate a random string
func StringCrypto ¶
only take in a length, and will use a default characters set to generate a random string
func StringCryptoWithCharset ¶
take in a character set and a length and will generate a random string using that character set.
func StringMath ¶
only take in a length, and will use a default characters set to generate a random string
func StringMathWithCharset ¶
take in a character set and a length and will generate a random string using that character set.
func StringWithCharset ¶
take in a character set and a length and will generate a random string using that character set.
Types ¶
This section is empty.