Documentation ¶
Index ¶
- Variables
- func Decrypt(encryptd []byte, decrypter Decrypter) ([]byte, error)
- func Defaults(key []byte) (Encrypter, Decrypter)
- func Encrypt(plaintext []byte, encrypter Encrypter) ([]byte, error)
- func GenerateSecretKey() []byte
- func HumanReadableKey(key []byte) string
- func ParseHumanReadableKey(key string) ([]byte, error)
- type Decrypter
- type Encrypter
- type ErrCannotDecrypt
- type NACLSecretbox
Constants ¶
This section is empty.
Variables ¶
var NoopCrypter = noopCrypter{}
NoopCrypter is just a pass-through crypter - it does not actually encrypt or decrypt any data
Functions ¶
func Decrypt ¶
Decrypt turns a slice of bytes serialized as an MaybeEncryptedRecord into a slice of plaintext bytes
func GenerateSecretKey ¶
func GenerateSecretKey() []byte
GenerateSecretKey generates a secret key that can be used for encrypting data using this package
func HumanReadableKey ¶
HumanReadableKey displays a secret key in a human readable way
func ParseHumanReadableKey ¶
ParseHumanReadableKey returns a key as bytes from recognized serializations of said keys
Types ¶
type Decrypter ¶
type Decrypter interface {
Decrypt(api.MaybeEncryptedRecord) ([]byte, error)
}
A Decrypter can decrypt an encrypted record
type Encrypter ¶
type Encrypter interface {
Encrypt(data []byte) (*api.MaybeEncryptedRecord, error)
}
A Encrypter can encrypt some bytes into an encrypted record
type ErrCannotDecrypt ¶
type ErrCannotDecrypt struct {
// contains filtered or unexported fields
}
ErrCannotDecrypt is the type of error returned when some data cannot be decryptd as plaintext
func (ErrCannotDecrypt) Error ¶
func (e ErrCannotDecrypt) Error() string
type NACLSecretbox ¶
type NACLSecretbox struct {
// contains filtered or unexported fields
}
NACLSecretbox is an implementation of an encrypter/decrypter. Encrypting generates random Nonces.
func NewNACLSecretbox ¶
func NewNACLSecretbox(key []byte) NACLSecretbox
NewNACLSecretbox returns a new NACL secretbox encrypter/decrypter with the given key
func (NACLSecretbox) Algorithm ¶
func (n NACLSecretbox) Algorithm() api.MaybeEncryptedRecord_Algorithm
Algorithm returns the type of algorithm this is (NACL Secretbox using XSalsa20 and Poly1305)
func (NACLSecretbox) Decrypt ¶
func (n NACLSecretbox) Decrypt(record api.MaybeEncryptedRecord) ([]byte, error)
Decrypt decrypts a MaybeEncryptedRecord and returns some bytes
func (NACLSecretbox) Encrypt ¶
func (n NACLSecretbox) Encrypt(data []byte) (*api.MaybeEncryptedRecord, error)
Encrypt encrypts some bytes and returns an encrypted record