crypto

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoNonce = fmt.Errorf("ciphertext smaller than nonce")

Functions

func Checksum

func Checksum(data []byte) []byte

Checksum wraps the sha256.Sum256 method to return a []byte instead of a [32]byte array.

func CompareChecksum

func CompareChecksum(hash, pass []byte) bool

func Decrypt

func Decrypt(ct []byte, key []byte) (clt []byte, err error)

Decrypt decrypts ct with key with the AES encryption algorithm. It automatically extracts the salt from the ct.

func DeriveKey

func DeriveKey(pw []byte, salt []byte) (key []byte)

DeriveKey generates an AES algorithm key from pw, using the SHA-256 hash algorithm and the provided salt.

func Encrypt

func Encrypt(src []byte, key []byte) (enc []byte, err error)

Encrypt encrypts src with key using the AES encryption algorithm. It automatically generates a random salt and appends to the front of the ciphertext.

func PassChecksum

func PassChecksum(data []byte) []byte

Checksum wraps the bcrypt.GenerateFromPassword method and returns the data's checksum.

func RandBytes

func RandBytes(len int) []byte

RandBytes generates an array of cryptographically secure random bytes with the provided length.

Types

This section is empty.

Jump to

Keyboard shortcuts

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