secretbox

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2025 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKeySize = errors.New("invalid key size: must be 32 bytes")
View Source
var ErrNoEncryptionKey = errors.New("encryption key is required")
View Source
var ErrShortCipherText = errors.New("ciphertext too short")
View Source
var ErrZeroKey = errors.New("encryption key cannot be all zeros")

Functions

func DecryptStringWithKey

func DecryptStringWithKey(data, key []byte) ([]byte, error)

DecryptStringWithKey decrypts data using secretbox with the provided key

func EncryptWithKey

func EncryptWithKey(data, key []byte) ([]byte, error)

EncryptWithKey encrypts data using NaCl's secretbox with the provided key. 40 bytes of overhead (24-byte nonce + 16-byte MAC) are added to the plaintext size.

func GenerateKey

func GenerateKey() ([]byte, error)

GenerateKey generates a random 32-byte key to be used by EncryptWithKey and DecryptWithKey

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL