localsecrets

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package localsecrets provides a way to encrypt and decrypt small messages without making network calls to a third party service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteKey

func ByteKey(sk string) [32]byte

ByteKey takes a secret key as a string and converts it to a [32]byte, cropping it if necessary.

Types

type Keeper

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

Keeper holds a secret for use in symmetric encryption, and implements driver.Crypter.

func NewKeeper

func NewKeeper(sk [32]byte) *Keeper

NewKeeper takes a secret key and returns a Keeper.

func (*Keeper) Decrypt

func (k *Keeper) Decrypt(ctx context.Context, message []byte) ([]byte, error)

Decrypt decryptes a message using a nonce that is read out of the first nonceSize bytes of the message and a secret held in the Keeper.

func (*Keeper) Encrypt

func (k *Keeper) Encrypt(ctx context.Context, message []byte) ([]byte, error)

Encrypt encrypts a message using a per-message generated nonce and the secret held in the Keeper.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳