AcediaDocumentation

Cryptography

Encryption, hashes, authentication codes and random bytes.

These functions return different kinds of strings:

CallResult
crypt.randomRaw bytes
crypt.hashHex text
crypt.hmacBase64 text

Encryption: crypt.encrypt and crypt.decrypt use AES-256-CBC with PKCS#7 padding. CBC does not provide an authentication tag. Check the key and IV encoding on each function page before combining these calls.

Functions

FunctionPurpose
crypt.generatekeyGenerates 32 random bytes and returns them in Base64.
crypt.encryptEncrypts bytes using AES-256-CBC with PKCS#7 padding.
crypt.decryptDecrypts Base64 AES-256-CBC ciphertext.
crypt.hashComputes a hash and returns lowercase hexadecimal text.
crypt.hmacComputes an HMAC and returns its digest in Base64.
crypt.randomGenerates random bytes as a raw string.
crypt.generatebytesGenerates random bytes and encodes them in Base64.

On this page