River

riversecretbox

package
v0.12.0 Latest
Published: Apr 9, 2025 License: Proprietary

Package riversecretbox provides a riverencrypt.Encryptor implementation that uses NaCl Secretbox, a good default encryption choice using widely respected cryptography.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encryptor

type Encryptor struct {/* contains filtered or unexported fields */}

func NewEncryptor

func NewEncryptor(keys ...[keySize]byte) *Encryptor

NewEncryptor returns a new Encryptor, an encryptor making use of NaCl Secretbox for use with riverencrypt.EncryptHook.

Multiple encryption keys may be specified for purposes of key rotation. When encrypting data, the first key is always used. When decrypting, all keys are tried, starting with the first, and an error is only returned if no key is capable of decrypting encrypted data. When rotating keys, initialize the lifecycle with the new key first and old key second. After all jobs that need to the old key be decrypted have rotated out of the database, remove the old key, after which the key rotation is complete.

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(cipher []byte) ([]byte, error)

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(plain []byte) []byte