Encrypt binary data with ChaCha20-Poly1305 (RFC 8439).
Uses a random 12-byte nonce. Callers must ensure a given key is not reused
for more than ~2^32 encryptions to avoid nonce collision. For high-volume
random-nonce use cases, prefer xchachaEncrypt (24-byte nonce).
Parameters
data: Uint8Array
Binary data to encrypt.
key: Uint8Array
32-byte encryption key.
Returns {ciphertext:Uint8Array;nonce:Uint8Array}
Object containing the ciphertext (with 16-byte Poly1305 tag appended) and nonce.
Encrypt binary data with ChaCha20-Poly1305 (RFC 8439).
Uses a random 12-byte nonce. Callers must ensure a given key is not reused for more than ~2^32 encryptions to avoid nonce collision. For high-volume random-nonce use cases, prefer xchachaEncrypt (24-byte nonce).