symmetric

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// NonceBytes is the length of GCM nonce.
	NonceBytes = 12

	// KeyBytes is the length of GCM key.
	KeyBytes = 32
)

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 FromBytes added in v0.1.12

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

FromBytes returns a key by decoding bytes.

func FromString added in v0.1.12

func FromString(k string) (*Key, error)

FromString returns a key by decoding a base32-encoded string.

func New added in v0.1.12

func New() *Key

New returns Key if err is nil and panics otherwise.

func NewRandom added in v0.1.12

func NewRandom() (*Key, error)

NewRandom returns a random key.

func (*Key) Bytes

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

Bytes returns raw key bytes.

func (*Key) Decrypt

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

Decrypt uses key 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) MarshalBinary added in v0.1.12

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

MarshalBinary implements BinaryMarshaler.

func (*Key) String added in v0.1.12

func (k *Key) String() string

String returns the base32-encoded string representation of raw key bytes.

Jump to

Keyboard shortcuts

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