crypto

package
v0.0.0-...-39f4860 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashSaltLen = 64
	HashKeyLen  = 64 // 128-bit salt according to NIST SP 800-132

)

Variables

View Source
var ErrInvalidSaltLen = fmt.Errorf("invalid salt length must be %d bytes", HashKeyLen)

Functions

func Decrypt

func Decrypt(ciphertext []byte, key []byte) ([]byte, error)

func DeriveKey

func DeriveKey(password string, salt []byte) ([]byte, error)

Generate a random 128-bit salt according to NIST SP 800-132 Uses Argon2id to derive a 256-bit key from the password

func Encrypt

func Encrypt(plaintext []byte, key []byte) ([]byte, error)

func GenerateNonce

func GenerateNonce(n uint8) []byte

func HashData

func HashData(data []byte) []byte

func HashDataWithSalt

func HashDataWithSalt(data, salt []byte) []byte

func HashStringData

func HashStringData(data string) []byte

func HashStringWithSalt

func HashStringWithSalt(data string, salt []byte) []byte

func VerifyBytes

func VerifyBytes(data []byte, hash []byte) bool

func VerifyString

func VerifyString(data string, hash []byte) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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