package random
import "go.mau.fi/util/random"
Index ¶
- 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 Token(namespace string, randomLength int) string
Functions ¶
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 String ¶
String generates a random string of the given length.
func StringBytes ¶
StringBytes generates a random string of the given length and returns it as a byte array.
func Token ¶
Token generates a GitHub-style token with the given prefix, a random part, and a checksum at the end. The format is `prefix_random_checksum`. The checksum is always 6 characters.
Source Files ¶
bytes.go string.go
- Version
- v0.8.6 (latest)
- Published
- Mar 16, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 1 week ago –
Tools for package owners.