Crypto Lib
    Preparing search index...

    Function createEncryptStream

    • Create a TransformStream that encrypts data with XChaCha20-Poly1305 in the STREAM construction.

      Emits the header (a fresh 24-byte base nonce) at once and each chunk as soon as the next byte shows it is not the last, so it holds at most one chunk of plaintext; the output is the same as streamEncrypt's.

      Parameters

      Returns TransformStream<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>

      A TransformStream that accepts plaintext Uint8Array chunks and emits ciphertext.

      const key = "aa".repeat(32);
      await readable
      .pipeThrough(createEncryptStream({ key }))
      .pipeTo(writable);