encrypt

package
v0.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: BlueOak-1.0.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// KeySize is the size of the encryption key.
	KeySize = 32
	// SaltSize is the size of the argon2id salt.
	SaltSize = 16
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypter

type Crypter interface {
	// Encrypt encrypts the plaintext.
	Encrypt(b []byte) ([]byte, error)
	// Decrypt decrypts the ciphertext created by Encrypt.
	Decrypt(b []byte) ([]byte, error)
	// Serialize serializes the Crypter. Use the Deserialize function to create
	// a Crypter from the resulting bytes. Deserializing requires the password
	// used to create the Crypter.
	Serialize() []byte
	// Close zeros the encryption key. The Crypter is useless after closing.
	Close()
}

Crypter is an interface for an encryption key and encryption/decryption algorithms. Create a Crypter with the NewCrypter function.

func Deserialize

func Deserialize(pw, encCrypter []byte) (Crypter, error)

Deserialize deserializes the Crypter for the password.

func NewCrypter

func NewCrypter(pw []byte) Crypter

NewCrypter derives an encryption key from a password string.

type Key

type Key [KeySize]byte

Key is 32 bytes.

type Salt

type Salt [SaltSize]byte

Salt is randomness used as part of key derivation. This is different from the salt generated during xchacha20poly1305 encryption, which is shorter.

Jump to

Keyboard shortcuts

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