aes

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package aes provides wrappers for AES-GCM encryption and decryption.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(ciphertext []byte, key *[32]byte) (plaintext []byte, err error)

Decrypt decrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.

The implementation is copied (and then trivially-altered) from https://github.com/gtank/cryptopasta/blob/bc3a108a5776376aa811eea34b93383837994340/encrypt.go#L57-L80

func Encrypt

func Encrypt(plaintext []byte, key *[32]byte) (ciphertext []byte, err error)

Encrypt encrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.

The implementation is copied (and then trivially-altered) from https://github.com/gtank/cryptopasta/blob/bc3a108a5776376aa811eea34b93383837994340/encrypt.go#L34-L55

func NewEncryptionKey

func NewEncryptionKey() (*[32]byte, error)

NewEncryptionKey generates a random 256-bit key for Encrypt() and Decrypt()

The implementation is copied (and trivially-altered) from https://github.com/gtank/cryptopasta/blob/bc3a108a5776376aa811eea34b93383837994340/encrypt.go#L23-L32

Types

type Redacter

type Redacter struct {
	Key *[32]byte
}

An Redacter translates between plaintext secret tokens and AES-encrypted tokens

func (*Redacter) Redact

func (r *Redacter) Redact(plaintext string) (string, error)

Redact returns an AES-256 GCM encrypted, base64-redacted version of the plaintext

func (*Redacter) Unredact

func (r *Redacter) Unredact(ciphertextBase64 string) (string, error)

Unredact unredacts an AES-256 GCM encrypted, base64-redacted secret into plaintext

Jump to

Keyboard shortcuts

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