Appearance
@pqc-sdk/core / encryptWebStream
Function: encryptWebStream()
encryptWebStream(
publicKey,options?):TransformStream<Uint8Array<ArrayBufferLike>,Uint8Array<ArrayBufferLike>>
encryptStream as a Web Streams TransformStream, for pipeThrough/pipeTo pipelines on runtimes with the WHATWG Streams API (Node 18+, Deno, Cloudflare Workers — see docs/compatibility.md for which are actually verified). A thin wrapper: all the cryptographic work happens in encryptStream, this only bridges the two shapes.
Parameters
publicKey
options?
Returns
TransformStream<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>
Example
ts
import { createReadStream, createWriteStream } from 'node:fs';
import { Readable, Writable } from 'node:stream';
import { pqc } from '@pqc-sdk/core';
const pair = await pqc.keys.generate();
await Readable.toWeb(createReadStream('large-file.bin'))
.pipeThrough(pqc.encryptWebStream(pair.publicKey))
.pipeTo(Writable.toWeb(createWriteStream('large-file.bin.enc')));