Documentation ¶
Overview ¶
Package keygen provides functionality for generating API client IDs and secrets
Index ¶
- Constants
- func Alpha(n int) string
- func AlphaNumeric(n int) string
- func CryptoRandInt() uint64
- func Decrypt(cipherText string, key string) ([]byte, error)
- func Encrypt(data []byte, key string) (string, error)
- func Equal(hash1 string, hash2 string) bool
- func GenerateRandomBytes(size int) []byte
- func GenerateRandomString(size int) string
- func GenerateRandomStringHex(size int) string
- func GenerateSHA256Hmac(secret string, data []byte) string
- func HS256(text string, secret string) string
- func HS512(text string, secret string) string
- func Hash(value string) string
- func HashFromBytes(value []byte) string
- func HashInput(input string) (string, error)
- func KeyID() string
- func PrefixedSecret(prefix string) string
- func S256Challenge(code string) string
- func SHA256(text string) string
- func SHA512(text string) string
- func Secret() string
Constants ¶
const ( KeyIDLength = 32 SecretLength = 64 ByteLength = 8 )
Defaults for the length of key IDs and secrets
Variables ¶
This section is empty.
Functions ¶
func Alpha ¶
Alpha generates a random string of n characters that only includes upper and lowercase letters (no symbols or digits)
func AlphaNumeric ¶
AlphaNumeric generates a random string of n characters that includes upper and lowercase letters and the digits 0-9
func CryptoRandInt ¶
func CryptoRandInt() uint64
CryptoRandInt function generates a random 64-bit unsigned integer using cryptographic methods
func GenerateRandomBytes ¶
GenerateRandomBytes returns random bytes
func GenerateRandomString ¶
GenerateRandomString returns a random string
func GenerateRandomStringHex ¶
GenerateRandomStringHex returns a random hexadecimal string
func GenerateSHA256Hmac ¶
GenerateSHA256Hmac generates a SHA-256 HMAC by using the secret as the key and the data as the message
func HashFromBytes ¶
HashFromBytes returns a SHA-256 checksum of the input
func KeyID ¶
func KeyID() string
KeyID returns a random ID that is of a fixed length with only alpha characters
func PrefixedSecret ¶
PrefixedSecret returns a prefixed random string of a fixed length with alpha-numeric characters
func S256Challenge ¶
S256Challenge creates [RFC 7636]: https://datatracker.ietf.org/doc/html/rfc7636#section-4.2
Types ¶
This section is empty.