yarn add js-chacha20
import JSChaCha20 from "js-chacha20";const key = Uint8Array([...]); // 32 bytes keyconst nonce = Uint8Array([...]); // 12 bytes nonceconst message = Uint8Array([...]); // some data as bytes array// Encrypt //const encrypt = new JSChaCha20(key, nonce).encrypt(message);// now encrypt contains bytes array of encrypted message
import JSChaCha20 from "js-chacha20";const key = Uint8Array([...]); // 32 bytes keyconst nonce = Uint8Array([...]); // 12 bytes nonceconst encrypt = Uint8Array([...]); // some data as bytes array// Encrypt //const message = new JSChaCha20(key, nonce).decrypt(encrypt);// now message contains bytes array of original message