encrypt

package
v0.0.0-...-2655f85 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSecret = errors.New("failed secret")

ErrSecret is an error when the secret hash is incorrect.

Functions

func DecryptFile

func DecryptFile(secret string, m *Msg, dst io.Writer) error

DecryptFile writes decrypted content of file with path from Msg.Value, checking Msg.Hash to dst using the secret and Msg.Salt.

func DecryptText

func DecryptText(secret string, m *Msg) (string, error)

DecryptText returns decrypted value from Msg.Value using the secret. Salt in m.Salt is expected

func Hash

func Hash(data []byte) []byte

Hash returns SHA3 ShakeSum256 check sum with length 32 bit.

func Key

func Key(secret string, salt []byte) ([]byte, []byte)

Key calculates and returns secret key and its SHA512 hash.

func Random

func Random(n int) ([]byte, error)

Random returns n-Random bytes.

func Salt

func Salt() ([]byte, error)

Salt returns Random bytes.

Types

type Msg

type Msg struct {
	Salt  string
	Value string
	Hash  string
	// contains filtered or unexported fields
}

Msg is struct with base parameter/results of encryption/decryption.

func File

func File(secret string, src io.Reader, base, name string) (*Msg, error)

File encrypts content from src to a new file using the secret. Salt and key hash are returned as Msg.Salt and Msg.Hash. The name if new file will be stored in m.Value.

func Text

func Text(secret, plainText string) (*Msg, error)

Text encrypts plaintText using the secret. Cipher message will be returned as Msg.Value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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