Documentation
¶
Index ¶
- Variables
- func DecodeKey(encoded string) ([]byte, error)
- func EncodeKey(key []byte) string
- func GenerateKey() ([]byte, error)
- type Encryptor
- func (e *Encryptor) Decrypt(ciphertext string) ([]byte, error)
- func (e *Encryptor) DecryptMap(data map[string]interface{}, sensitiveKeys map[string]bool) error
- func (e *Encryptor) DecryptString(ciphertext string) (string, error)
- func (e *Encryptor) Encrypt(plaintext []byte) (string, error)
- func (e *Encryptor) EncryptMap(data map[string]interface{}, sensitiveKeys map[string]bool) error
- func (e *Encryptor) EncryptString(plaintext string) (string, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidCiphertext = errors.New("invalid ciphertext") ErrInvalidKey = errors.New("invalid encryption key") )
Functions ¶
func GenerateKey ¶
GenerateKey generates a random 32-byte encryption key
Types ¶
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
Encryptor provides encryption/decryption operations using XChaCha20-Poly1305
func NewEncryptor ¶
NewEncryptor creates a new encryptor with the given 32-byte key
func (*Encryptor) DecryptMap ¶
DecryptMap decrypts all string values in a map that match the given keys
func (*Encryptor) DecryptString ¶
DecryptString decrypts a base64-encoded ciphertext to a string
func (*Encryptor) Encrypt ¶
Encrypt encrypts plaintext and returns base64-encoded ciphertext with nonce prepended
func (*Encryptor) EncryptMap ¶
EncryptMap encrypts all string values in a map that match the given keys
Click to show internal directories.
Click to hide internal directories.