crypt

package
v0.28.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

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

Decrypt decrypts data using 256-bit AES-GCM.

func DecryptFromHex

func DecryptFromHex(hexCiphertext string, hexKey string) ([]byte, error)

func Encrypt

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

Encrypt encrypts data using 256-bit AES-GCM.

func EncryptAndHex

func EncryptAndHex(plaintext []byte, hexKey string) (string, error)

func GenerateHMAC

func GenerateHMAC(data []byte, key []byte) []byte

GenerateHMAC produces a SHA-512/256 hash using 256-bit key

func GenerateHMACFromHex

func GenerateHMACFromHex(data []byte, hexKey string) (string, error)

GenerateHMACFromHex produces a SHA-512/256 hash using 256-bit key

func GenerateRandomStringFromLetters added in v0.11.2

func GenerateRandomStringFromLetters(length int, letterRunes []rune) string

GenerateRandomStringFromLetters generates a random string of the given length using the provided runes this function panics if - the provided length is less than 1 - if the provided runes are empty - if os fails to read random bytes

func NewEncryptionKey

func NewEncryptionKey() (*[32]byte, error)

NewEncryptionKey generates a random 256-bit key

func NewEncryptionKeyInHex

func NewEncryptionKeyInHex() (string, error)

func VerifyHMAC

func VerifyHMAC(data []byte, key []byte, suppliedMAC []byte) bool

VerifyHMAC checks the supplied MAC against the hash of the data using the key

func VerifyHMACFromHex

func VerifyHMACFromHex(data []byte, hexKey string, suppliedHexMAC string) (bool, error)

VerifyHMACFromHex checks the supplied MAC against the hash of the data using the key

Types

This section is empty.

Jump to

Keyboard shortcuts

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