rand

package
v1.2.77 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

package rand_ Creating Random Strings in Go

Index

Constants

View Source
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 Bytes

func Bytes(n int) []byte

Bytes returns securely generated random bytes.

func BytesCrypto

func BytesCrypto(n int) ([]byte, error)

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

func BytesMath(n int) []byte

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

func String(len int) string

only take in a length, and will use a default characters set to generate a random string

func StringCrypto

func StringCrypto(length int64) (string, error)

only take in a length, and will use a default characters set to generate a random string

func StringCryptoWithCharset

func StringCryptoWithCharset(length int64, charset string) (string, error)

take in a character set and a length and will generate a random string using that character set.

func StringMath

func StringMath(length int) string

only take in a length, and will use a default characters set to generate a random string

func StringMathWithCharset

func StringMathWithCharset(length int, charset string) string

take in a character set and a length and will generate a random string using that character set.

func StringWithCharset

func StringWithCharset(len int, charset string) string

take in a character set and a length and will generate a random string using that character set.

Types

This section is empty.

Jump to

Keyboard shortcuts

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