refactor meta/internal/crypto and add key generation method

This commit is contained in:
Fabio Bozzo
2024-11-12 15:29:48 +01:00
parent 7cb0f97b30
commit 3987e8649c
6 changed files with 142 additions and 64 deletions

View File

@@ -44,6 +44,15 @@ func WithMeta(key string, val any) Option {
}
}
// WithEncryptedMeta adds a key/value pair in the "meta" field.
// The value is encrypted with the given aesKey.
// Accepted types for the value are: string, []byte.
func WithEncryptedMeta(key string, val any, encryptionKey []byte) Option {
return func(t *Token) error {
return t.meta.AddEncrypted(key, val, encryptionKey)
}
}
// WithNonce sets the Token's nonce with the given value.
//
// If this option is not used, a random 12-byte nonce is generated for