Encrypt plaintext using ChaCha20-Poly1305, preferring WebCrypto when available.
Output format: base64(nonce (12B) || ciphertext || tag (16B)). Falls back to @noble/ciphers when WebCrypto does not support ChaCha20-Poly1305.
const result = await modernChaCha20Encrypt({ key: "a".repeat(64), plaintext: "hello world",});console.log(result.ciphertext); // base64 string Copy
const result = await modernChaCha20Encrypt({ key: "a".repeat(64), plaintext: "hello world",});console.log(result.ciphertext); // base64 string
Encrypt plaintext using ChaCha20-Poly1305, preferring WebCrypto when available.
Output format: base64(nonce (12B) || ciphertext || tag (16B)). Falls back to @noble/ciphers when WebCrypto does not support ChaCha20-Poly1305.