encryption

package
v0.0.0-...-2f05a08 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoopCrypter = noopCrypter{}

NoopCrypter is just a pass-through crypter - it does not actually encrypt or decrypt any data

Functions

func Decrypt

func Decrypt(encryptd []byte, decrypter Decrypter) ([]byte, error)

Decrypt turns a slice of bytes serialized as an MaybeEncryptedRecord into a slice of plaintext bytes

func Defaults

func Defaults(key []byte) (Encrypter, Decrypter)

Defaults returns a default encrypter and decrypter

func Encrypt

func Encrypt(plaintext []byte, encrypter Encrypter) ([]byte, error)

Encrypt turns a slice of bytes into a serialized MaybeEncryptedRecord slice of bytes

func GenerateSecretKey

func GenerateSecretKey() []byte

GenerateSecretKey generates a secret key that can be used for encrypting data using this package

func HumanReadableKey

func HumanReadableKey(key []byte) string

HumanReadableKey displays a secret key in a human readable way

func ParseHumanReadableKey

func ParseHumanReadableKey(key string) ([]byte, error)

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

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

Jump to

Keyboard shortcuts

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