Crypto Lib
    Preparing search index...

    Function createEncryptStream

    • Create a TransformStream that encrypts data with XChaCha20-Poly1305.

      Accumulates all input chunks, then on flush encrypts the combined plaintext and emits nonce (24 B) || ciphertext || tag (16 B).

      Parameters

      Returns TransformStream<unknown>

      A TransformStream that accepts Uint8Array chunks and emits encrypted output.

      const key = "aa".repeat(32);
      const stream = createEncryptStream({ key });
      const writer = stream.writable.getWriter();
      await writer.write(new Uint8Array([1, 2, 3]));
      await writer.close();