cipher

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrContentTooShort is returned when caller tries to decrypt a content which is too short
	ErrContentTooShort = fmt.Errorf("the content must be at least %d for decryption", chacha20poly1305.NonceSizeX)
)

Functions

func Decrypt

func Decrypt(key [32]byte, id, content []byte) ([]byte, error)

Decrypt derives the premary key with the given id and a random value. It reads the first bytes to get the derivation seed and tries to decrypt the content. Returns the aead.Open error if any.

func Encrypt

func Encrypt(key [32]byte, id, content []byte) []byte

Encrypt derives the premary key with the given id and a random value. Returns the corresponding encrypted content with the random seed for derivation. The returned value can be decrypted by using the same key and id with Decrypt function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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