crypter

package module
v0.0.0-...-28bb5b7 Latest Latest
Warning

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

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

README

crypter

import "github.com/alfred-landrum/crypter"

Overview

Package crypter provides convienence wrapping around the nacl/secretbox package.

Index

Package files

crypter.go

Constants

const (
    KeySize = 32

    // 24 bytes for nonce + minimum secretbox length
    Overhead = 24 + secretbox.Overhead
)

Sizes and minimums set by secretbox

type Box

type Box struct {
    Key [KeySize]byte
}

A Box is generated from a Key, and can encrypt & decrypt "small" messages, using nacl/secretbox.

func NewBox
func NewBox(key Key) (*Box, error)

NewBox creates a new crypter box from the given key, failing only if the key wasn't created from NewKey.

func (*Box) Decrypt
func (b *Box) Decrypt(data []byte) ([]byte, error)

Decrypt uses secretbox.Open to authenticate & decrypt data.

func (*Box) Encrypt
func (b *Box) Encrypt(data []byte) []byte

Encrypt uses secretbox.Seal to authenticate & encrypt the data.

type Key

type Key string

A Key is a base64 RawURLEncoded 32 byte sequence.

func NewKey
func NewKey() Key

NewKey generates a new appropriately sized key.


Generated by godoc2md

Documentation

Overview

Package crypter provides convienence wrapping around the nacl/secretbox package.

Index

Constants

View Source
const (
	KeySize = 32

	// 24 bytes for nonce + minimum secretbox length
	Overhead = 24 + secretbox.Overhead
)

Sizes and minimums set by secretbox

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

type Box struct {
	Key [KeySize]byte
}

A Box is generated from a Key, and can encrypt & decrypt "small" messages, using nacl/secretbox.

func NewBox

func NewBox(key Key) (*Box, error)

NewBox creates a new crypter box from the given key, failing only if the key wasn't created from NewKey.

func (*Box) Decrypt

func (b *Box) Decrypt(data []byte) ([]byte, error)

Decrypt uses secretbox.Open to authenticate & decrypt data.

func (*Box) Encrypt

func (b *Box) Encrypt(data []byte) []byte

Encrypt uses secretbox.Seal to authenticate & encrypt the data.

type Key

type Key string

A Key is a base64 RawURLEncoded 32 byte sequence.

func NewKey

func NewKey() Key

NewKey generates a new appropriately sized key.

Jump to

Keyboard shortcuts

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