Documentation
¶
Overview ¶
Package token provides secure opaque token generation and lookup hashing.
Index ¶
Constants ¶
View Source
const ( // MinLookupKeyBytes is the minimum application-controlled HMAC key length // for token lookup hashes. MinLookupKeyBytes = 32 )
Variables ¶
View Source
var ( // ErrInvalidLength reports an unsafe token byte length. ErrInvalidLength = errors.New("token: invalid length") // ErrEmptyToken reports that a token value was empty. ErrEmptyToken = errors.New("token: empty token") // ErrWeakLookupKey reports that an HMAC lookup key is too short. ErrWeakLookupKey = errors.New("token: weak lookup key") )
Functions ¶
func GenerateAPIKeySecret ¶
GenerateAPIKeySecret returns a URL-safe opaque API key secret.
func GenerateOpaque ¶
GenerateOpaque returns a URL-safe opaque value with at least 128 bits of entropy.
func GeneratePublicID ¶
GeneratePublicID returns a URL-safe public identifier.
func HMACLookupHash ¶
HMACLookupHash returns an HMAC-SHA-256 lookup hash for a high-entropy random token using an application-controlled lookup key.
func LookupHash ¶
LookupHash returns a SHA-256 lookup hash for a high-entropy random token.
This is appropriate for high-entropy API keys generated by this package. It is not suitable for human passwords.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.