crypto

package
v0.1.10 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToKey

func BytesToKey(salt, data []byte, h hash.Hash, keyLen, blockLen int) (key, iv []byte)

From https://github.com/walkert/go-evp . BytesToKey implements the Openssl EVP_BytesToKey logic. It takes the salt, data, a hash type and the key/block length used by that type. As such it differs considerably from the openssl method in C.

func DecryptCryptoJsAesMsg

func DecryptCryptoJsAesMsg(password string, ciphertext string) ([]byte, error)

Decrypt a CryptoJS.AES.encrypt(msg, password) encrypted msg. ciphertext is the result of CryptoJS.AES.encrypt(), which is the base64 string of "Salted__" + [8 bytes random salt] + [actual ciphertext]. actual ciphertext is padded (make it's length align with block length) using Pkcs7. CryptoJS use an OpenSSL-compatible EVP_BytesToKey to derive (key,iv) from (password,salt), using md5 as hash type and 32 / 16 as length of key / block. See: https://stackoverflow.com/questions/35472396/how-does-cryptojs-get-an-iv-when-none-is-specified , https://stackoverflow.com/questions/64797987/what-is-the-default-aes-config-in-crypto-js .

func Md5String

func Md5String(inputs ...string) string

Return the MD5 hex hash string (lower-case) of input string(s).

Types

This section is empty.

Jump to

Keyboard shortcuts

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