cryptoUtil

package
v0.0.0-...-3c1832a Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodedHash

func DecodedHash(s string) ([]byte, error)

DecodedHash returns the decoded hash of the given hex string

func DecryptAES256

func DecryptAES256(key []byte, securemess []byte) (decodedmess []byte, err error)

DecryptAES256 ....

func DecryptMessage

func DecryptMessage(message []byte, passPhrase string) ([]byte, error)

DecryptMessage decrypts an encrypted message using a password

func EncodedHash

func EncodedHash(s string) string

EncodedHash returns the hex encoded hash of the given string

func EncryptAES256

func EncryptAES256(key []byte, plaintext []byte) (encmess []byte, err error)

EncryptAES256 encrypts a message using AES-256-GCM

key is the encryption key (must be 32 bytes)
message is the string to be encrypted
returns the (b64 encoded) encrypted message, or an error if the key is not 32 bytes

func EncryptMessage

func EncryptMessage(message []byte, passPhrase string) ([]byte, error)

EncryptMessage encrypts a message using a password

func FNV32a

func FNV32a(text string) uint32

FNV32a hashes using fnv32a algorithm

func GenerateRecoveryPassword

func GenerateRecoveryPassword(answers []string, salt []byte) string

GenerateRecoveryPassword derives a strong key from a security answer using PBKDF2-HMAC-SHA256. The salt is unique per key (randomly generated at setup time and persisted in config), preventing cross-key rainbow table attacks. 600 000 iterations matches the OWASP 2023 recommendation for PBKDF2-HMAC-SHA256, making offline brute-force expensive.

func Hash

func Hash(s string) []byte

Hash using SHA3-256

func IndexFromString

func IndexFromString(text string) uint32

IndexFromString returns the unique (hash) index of an arbitrary string

func SecureRandomStr

func SecureRandomStr(length int) (string, error)

SecureRandomStr returns a random string of the given length

length: the length of the string to return
returns: a random string of the given length
				 error: if an error occurs
notes: uses crypto/rand to generate random bytes

Types

This section is empty.

Jump to

Keyboard shortcuts

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