symmetric

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

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

Key is a wrapper for a symmetric key.

func CreateKey

func CreateKey() (*Key, error)

CreateKey returns 44 random bytes, 32 for the key and 12 for a nonce.

func NewKey

func NewKey(k []byte) (*Key, error)

NewKey returns a key by wrapping k.

func (*Key) Bytes

func (k *Key) Bytes() []byte

Bytes returns raw key bytes. This is cleaner than marshal when your not dealing with an interface type.

func (*Key) Decrypt

func (k *Key) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt uses key (:32 key, 32:12 nonce) to perform AES-256 GCM decryption on ciphertext.

func (*Key) Encrypt

func (k *Key) Encrypt(plaintext []byte) ([]byte, error)

Encrypt performs AES-256 GCM encryption on plaintext.

func (*Key) Marshal

func (k *Key) Marshal() ([]byte, error)

Marshal returns raw key bytes.

Jump to

Keyboard shortcuts

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