crypto

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package crypto is used to encrypt and decrypt string data using symmetric key encryption.

Index

Constants

View Source
const (

	// DefaultCipherKeyLength is the required number of bytes for a cipher key.
	DefaultCipherKeyLength = 32
)

Variables

View Source
var (

	// ErrCipherKeyMissing is issued when an encrypt/decrypt needed but we don't have a cipher key.
	ErrCipherKeyMissing = fmt.Errorf("no cipher key provided")

	// ErrCipherKeyLength is issued when a key is not long enough.
	ErrCipherKeyLength = fmt.Errorf("cipher key must be %d bytes", DefaultCipherKeyLength)

	// ErrCipherPassword is issued when a cipher key cannot be generated from the provided password.
	ErrCipherPassword = fmt.Errorf("cannot generate cipher key from provided password")
)

Functions

func CipherKeyCheck

func CipherKeyCheck(key []byte) error

CipherKeyCheck will check the key meets starkdb requirements.

func Decrypt

func Decrypt(data string, cipherKey []byte) (string, error)

Decrypt will decrypt plaintext using symmetric key encryption.

func Encrypt

func Encrypt(data string, cipherKey []byte) (string, error)

Encrypt will encrypt plaintext using symmetric key encryption.

func Password2cipherkey

func Password2cipherkey(password string) ([]byte, error)

Password2cipherkey will take a password and produce a 32 byte cipher key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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