encryption

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: AGPL-3.0-only Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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