aes

package
v0.0.0-...-b602c5b Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const SALT_SIZE = 16

Variables

This section is empty.

Functions

func ExtractSalt

func ExtractSalt(ciphertext []byte) ([]byte, error)

ExtractSalt separates salt and ciphertext

func GenerateSalt

func GenerateSalt() ([]byte, error)

GenerateSalte securely generates a len(SALT_SIZE) byte salt

func PrependSalt

func PrependSalt(salt, ciphertext []byte) []byte

PrependSalt prepends salt to the ciphertext

Types

type AES256Decrypter

type AES256Decrypter struct {
	// Passphrase to be used to decrypt the AES256 ciphered blocks
	Passphrase string
}

AES256Decrypter implements the Decrypter interface. Provided a Passphrase it exposes a Decrypt method to read the content of AES256 encrypted bytes.

func NewAES256Decrypter

func NewAES256Decrypter(p string) *AES256Decrypter

NewAES256Decrypter builds a new AES256Decrypter object from Passphrase. The returned object can then be used against AES256 encrypted bytes using this Passphrase using the Decrypt method.

See Decrypter interface.

func (*AES256Decrypter) Decrypt

func (a *AES256Decrypter) Decrypt(ed []byte) ([]byte, error)

Decrypt reads up the AES256 encrypted data bytes from ed, decrypts them and returns the resulting plain data bytes as well as any potential errors.

type AES256Encrypter

type AES256Encrypter struct {
	Key *AES256Key
}

AES256Encrypter implements the Encrypter interface. Provided a AES256Key object it exposes a Encrypt method to encrypt provided plain bytes using AES256 algorithm.

func NewAES256Encrypter

func NewAES256Encrypter(Passphrase string, salt []byte) (*AES256Encrypter, error)

NewAES256Encrypter builds a new AES256Encrypter object from provided passphrase and salt. The returned object can then be used against byte slices to encrypt them with the AES256 encryption algorithm using the Encrypt method.

See Encrypter interface.

func (*AES256Encrypter) Encrypt

func (a *AES256Encrypter) Encrypt(pd []byte) ([]byte, error)

Encrypt reads up plain data bytes contained in pd, encrypts them using AES256 encryption algorithm, and returns the resulting bytes as well as any potential errors.

type AES256Key

type AES256Key struct {
	// contains filtered or unexported fields
}

func MakeAES256Key

func MakeAES256Key(passphrase string, salt []byte) (*AES256Key, error)

make an AES key. Pass nil as salt if you want to generate a new one otherwise pass the salt from the message and you will get the key will use scrypt to make it semi secure

func NewAES256Key

func NewAES256Key(key, salt []byte) *AES256Key

Generate a new AES256 key from a key and salt

Jump to

Keyboard shortcuts

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