crypt

package
v0.0.0-...-7447204 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLen = errors.New("invalid ciphertext length")
)

Functions

func Hash

func Hash(secret, salt []byte) []byte

func New256Key

func New256Key() [256]byte

NewKey generates a new random key value, of 256 bytes in size

func New32Key

func New32Key() [32]byte

NewKey generates a new random key value, of 256 bytes in size

func NewSalt

func NewSalt() [128]byte

NewSalt generates a new random salt value, of 128 bytes in size

Types

type Cryptographer

type Cryptographer interface {
	// NewSalt generates a new random salt value, of 128 bytes in size
	NewSalt() [128]byte
	// New256Key generates a new random key value, of 256 bytes in size
	New256Key() [256]byte
	// New32Key generates a new random key value, of 256 bytes in size
	New32Key() [32]byte
	// NewCipher generates a new AES cipher based on the input key
	NewCipher(key []byte) EncryptDecrypter
	// Random reads random bytes into the input byte slice
	Random(buffer []byte)
}

Cryptographer describes the set of cryptographic actions required by the app

type EncryptDecrypter

type EncryptDecrypter interface {
	// Encrypt will encrypt the input bytes `v` with the EncryptDecrypter key,
	// returning the ciphertext of `v` as a byte slice, and an error
	Encrypt(v []byte) ([]byte, error)

	// Decrypt will decipher the input bytes `v` with the EncryptDecrypter key,
	// returning the plaintext of `v` as a byte slice, and an error
	Decrypt(v []byte) ([]byte, error)
}

EncrypterDecrypter is a general purpose encryption interface that supports an Encrypt and a Decrypt method

func NewCipher

func NewCipher(key []byte) EncryptDecrypter

NewCipher generates a new AES cipher based on the input key

Jump to

Keyboard shortcuts

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