encryption

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// KeySize is the size of the keys created by GenerateKey()
	KeySize = 32
	// NonceSize is the size of the nonces created by GenerateNonce()
	NonceSize = 24
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(msg []byte, key *[KeySize]byte) ([]byte, error)

Decrypt extracts the nonce from the encrypted text, and attempts to decrypt with nacl.box.

func Encrypt

func Encrypt(msg []byte, key *[KeySize]byte) ([]byte, error)

Encrypt generates a random nonce and encrypts the input using nacl.secretbox package. We store the nonce in the first 24 bytes of the encrypted text.

func GenerateKey

func GenerateKey() (*[KeySize]byte, error)

GenerateKey generates a new random secret key.

func GenerateNonce

func GenerateNonce() (*[NonceSize]byte, error)

GenerateNonce creates a new random nonce.

Types

This section is empty.

Jump to

Keyboard shortcuts

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