Documentation ¶
Overview ¶
Cryptography that is useful for SaaS apps
Index ¶
- Constants
- Variables
- func DeobfuscateUint32(secret *Secret, idType string, obfuscatedID [4]byte) uint32
- func DeobfuscateUint64(secret *Secret, idType string, obfuscatedID [8]byte) uint64
- func ObfuscateUint32(secret *Secret, idType string, id uint32) [4]byte
- func ObfuscateUint64(secret *Secret, idType string, id uint64) [8]byte
- func Open(ciphertextString string, secret *Secret, usage string, value interface{}) error
- func Seal(secret *Secret, usage string, ttl time.Duration, value interface{}) string
- type BearerToken
- type Secret
Constants ¶
View Source
const SecretLen = 32
The length of an unencoded secret, in bytes
Variables ¶
View Source
var ErrExpired = errors.New("ciphertext has expired")
View Source
var ErrMalformedBearerToken = errors.New("malformed bearer token")
View Source
var ErrTampered = errors.New("ciphertext has been tampered")
Functions ¶
func DeobfuscateUint32 ¶
func DeobfuscateUint64 ¶
Types ¶
type BearerToken ¶
func BearerTokenFromRequest ¶
func ParseBearerToken ¶
func ParseBearerToken(appSecret *Secret, tokenPurpose string, token string) (*BearerToken, error)
func (*BearerToken) Encode ¶
func (token *BearerToken) Encode(appSecret *Secret, tokenPurpose string) string
func (*BearerToken) EncodeRedacted ¶
func (token *BearerToken) EncodeRedacted(appSecret *Secret, tokenPurpose string) string
Like Encode, but the secret bits are replaced with "..."
func (*BearerToken) Redact ¶
func (token *BearerToken) Redact() *BearerToken
Return a copy of token without Secret
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}
A secret that is used for deriving other secrets
func ParseSecret ¶
Parse a hex-encoded secret. hexString must be SecretLen*2 characters long
Click to show internal directories.
Click to hide internal directories.