symmetric

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 5 Imported by: 0

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

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

FromBytes returns a key by decoding bytes.

func FromString

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

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

func New

func New() *Key

New returns Key if err is nil and panics otherwise.

func NewRandom

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

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

MarshalBinary implements BinaryMarshaler.

func (*Key) String

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