Documentation
¶
Index ¶
- func AppendSequence[T any](n int, charset, output []T) []T
- func Bytes(n int) []byte
- func GetTokenPrefix(token string) string
- func IsToken(namespace, token string) bool
- func String(n int) string
- func StringBytes(n int) []byte
- func StringBytesCharset(n int, charset string) []byte
- func StringCharset(n int, charset string) string
- func Token(namespace string, randomLength int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendSequence ¶ added in v0.9.1
AppendSequence generates a random sequence of the given length using the given character set and appends it to the given output slice.
func Bytes ¶
Bytes generates the given amount of random bytes using crypto/rand, and panics if it fails.
func GetTokenPrefix ¶
GetTokenPrefix parses the given token generated with Token, validates the checksum and returns the prefix namespace.
func IsToken ¶
IsToken checks if the given token is a valid token generated with Token with the given namespace..
func StringBytes ¶
StringBytes generates a random string of the given length and returns it as a byte array.
func StringBytesCharset ¶ added in v0.9.1
StringBytesCharset generates a random string of the given length using the given character set and returns it as a byte array. Note that the character set must be ASCII. For arbitrary Unicode, use AppendSequence with a `[]rune`.
func StringCharset ¶ added in v0.9.1
StringCharset generates a random string of the given length using the given character set. Note that the character set must be ASCII. For arbitrary Unicode, use AppendSequence with a `[]rune`.
Types ¶
This section is empty.