Skip to content

Encryption (crypto AEAD & Symmetric)

AES-GCM

Hardware-accelerated authenticated encryption. Uses AES-NI instructions when available.

rust
import { aes_gcm_encrypt, aes_gcm_decrypt } from "crypto";

let key = ...;    // 16 or 32 bytes
let nonce = ...;  // 12 bytes
let plaintext = "Secret message".asBytes();

let ciphertext = aes_gcm_encrypt(key, nonce, plaintext, aad);
let decrypted = aes_gcm_decrypt(key, nonce, ciphertext, aad);

ChaCha20-Poly1305

Extremely fast AEAD cipher, especially on platforms without AES hardware (mobile/ARM).

rust
import { chacha20_poly1305_encrypt, chacha20_poly1305_decrypt } from "crypto";

let encrypted = chacha20_poly1305_encrypt(key, nonce, plaintext, aad);
let decrypted = chacha20_poly1305_decrypt(key, nonce, encrypted, aad);

Raw AES

Low-level AES block cipher for custom constructions.

rust
import { aes_encrypt_block, aes_decrypt_block } from "crypto";

Implementation Details

FilePurpose
aes.vxAES core (key expansion, SubBytes, MixColumns)
aes_gcm.vxGCM mode with GHASH authentication
chacha20.vxChaCha20 quarter-round stream cipher
poly1305.vxPoly1305 MAC with 130-bit accumulator
aead.vxUnified AEAD interface combining cipher + MAC

Released under the MIT License.