Crypto Lib
    Preparing search index...

    Function createHashStream

    • Create a TransformStream that computes a hash digest.

      Each input chunk is fed to the incremental hasher. On flush, a HashStreamResult containing the hex digest and algorithm name is emitted.

      Parameters

      Returns TransformStream<unknown>

      A TransformStream that accepts Uint8Array chunks and emits a HashStreamResult.

      const stream = createHashStream("sha256");
      const writer = stream.writable.getWriter();
      await writer.write(new TextEncoder().encode("hello"));
      await writer.close();
      const reader = stream.readable.getReader();
      const { value } = await reader.read();
      console.log(value.digest); // hex string