Cryptography utilities presented in a simple way
crypto
library and bcryptjs
to provide a simple and secure API for cryptographic operations.
hashWithSalt
for storing user passwordssymmetric.generatePassword()
: Generates a secure random passwordsymmetric.encrypt(text: string, password: string)
: Encrypts text using a passwordsymmetric.decrypt(encryptedText: string, password: string)
: Decrypts text using a passwordasymmetric.generateKeys()
: Generates a key pair (encryptKey
and decryptKey
)asymmetric.encrypt(encryptKey: string, text: string)
: Encrypts text using a public keyasymmetric.decrypt(decryptKey: string, encryptedText: string)
: Decrypts text using a private keysign.sign(payload: string, secret: string)
: Signs a payload with a secretsign.verify(payload: string, checksum: string, secret: string)
: Verifies a signed payloadhash.hash(text: string)
: Creates a hash from texthash.compare(text: string, hashed: string)
: Compares text with a hashhashWithSalt.hash(password: string)
: Creates a hash from a password with salthashWithSalt.compare(password: string, hashed: string)
: Compares a password with a hashed value