random

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MPL-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(n int) []byte

Bytes generates the given amount of random bytes using crypto/rand, and panics if it fails.

func GetTokenPrefix

func GetTokenPrefix(token string) string

GetTokenPrefix parses the given token generated with Token, validates the checksum and returns the prefix namespace.

func IsToken

func IsToken(namespace, token string) bool

IsToken checks if the given token is a valid token generated with Token with the given namespace..

func String

func String(n int) string

String generates a random string of the given length.

func StringBytes

func StringBytes(n int) []byte

StringBytes generates a random string of the given length and returns it as a byte array.

func Token

func Token(namespace string, randomLength int) string

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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