Documentation ¶
Index ¶
- func Decrypt(tok []byte, ttl time.Duration, k []*Key) (msg []byte)
- func DecryptWithTime(tok []byte, ttl time.Duration, k []*Key, now time.Time) (msg []byte)
- func Encrypt(msg []byte, k *Key) (tok []byte, err error)
- func EncryptWithTime(msg []byte, k *Key, encryptAt time.Time) (tok []byte, err error)
- type Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt verifies that tok is a valid fernet token that was signed with a key in k at most ttl time ago only if ttl is greater than zero. Returns the message contained in tok if tok is valid, otherwise nil.
func DecryptWithTime ¶
DecryptWithTime verifies that tok is a valid fernet token that was signed with a key in k at most ttl time ago only if ttl is greater than zero. Returns the message contained in tok if tok is valid, otherwise nil.
func Encrypt ¶
Encrypt encrypts and signs msg with key k and returns the resulting fernet token. If msg contains text, the text should be encoded with UTF-8 to follow fernet convention.
func EncryptWithTime ¶
EncryptWithTime encrypts and signs msg with key k at timestamp encryptAt and returns the resulting fernet token. If msg contains text, the text should be encoded with UTF-8 to follow fernet convention.
Types ¶
type Key ¶
type Key struct {
Value [32]byte
}
Key represents a key.
func DecodeKey ¶
DecodeKey decodes a key from s and returns it. The key can be in hexadecimal, standard base64, or URL-safe base64.
func DecodeKeys ¶
DecodeKeys decodes each element of k using DecodeKey and returns the resulting keys. Requires at least one key.
func GenerateKey ¶
func GenerateKey() *Key
Generate initializes k with pseudorandom data from package crypto/rand.