Documentation
¶
Index ¶
- Constants
- Variables
- type Random
- func (r *Random) GetAlphabet(length int, alphabet []rune) (string, error)
- func (r *Random) GetHex(length int) (string, error)
- func (r *Random) GetID() (string, error)
- func (r *Random) GetSecureBytes(length int) ([]byte, error)
- func (r *Random) MustGetAlphabet(length int, alphabet []rune) string
- func (r *Random) MustGetHex(length int) string
- func (r *Random) MustGetID() string
- func (r *Random) MustGetSecureBytes(length int) []byte
- func (r *Random) Read(buf []byte) (int, error)
Constants ¶
View Source
const (
IDLen = 16
)
Default ID length.
Variables ¶
View Source
var ( AlphaNum = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") LowerAlphaNum = []rune("abcdefghijklmnopqrstuvwxyz0123456789") )
Handy alphabets.
Functions ¶
This section is empty.
Types ¶
type Random ¶
type Random struct {
// contains filtered or unexported fields
}
Random provides random generation utilities.
func (*Random) GetAlphabet ¶
GetAlphabet gets a random string of the given length (in runes) composed of the given alphabet. The alphabet must be between 2 and 256 unique runes long.
func (*Random) GetID ¶
GetID calls GetAlphabet with sane default settings: 16-long, URL-safe lowercase, about 82 bits of entropy.
func (*Random) GetSecureBytes ¶
GetSecureBytes returns a byte slice of cryptographically secure random numbers of the given "length"
func (*Random) MustGetAlphabet ¶
MustGetAlphabet is like GetAlphabet but panics on error.
func (*Random) MustGetHex ¶
MustGetHex is like GetHex but panics on error.
func (*Random) MustGetSecureBytes ¶
MustGetSecureBytes is like GetSecureBytes but panics on error.
Click to show internal directories.
Click to hide internal directories.