You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decrypt file: 20MB file send from pgpainless(compression Zip)
pgpainless: 10Sec
OpenPGPJs: 3Min (chunk 2000+ times)
Decrypt file: 20MB file send from OpenPGPJs(compression Zip)
pgpainless: 10Sec
OpenPGPJs: 10Sec (chunk 60 times)
async function decrypt(pk){
const plainData2 = fs.readFileSync("C:\\Users\\Xing\\Desktop\\ttt\\video_20221202_150102.mp4");
const blob = new Blob([plainData2], { type: "" })
const stream = blob.stream();
console.log("stream",stream)
const privateKeyObj = await openpgp.readPrivateKey({ armoredKey: pk });
const message = await openpgp.readMessage({ binaryMessage: stream });
console.log("message-en",message)
const { data: decrypted } = await openpgp.decrypt({
message: message,
decryptionKeys: privateKeyObj,
format: 'binary',
config: { allowUnauthenticatedStream: true, preferredCompressionAlgorithm: openpgp.enums.compression.zlib }
});
const wstream= createWritableStream("C:\\Users\\Xing\\Desktop\\ttt\\1111111.mp4")
await decrypted.pipeTo(wstream)
}
function createWritableStream(destinationPath){
const sink = {
// this method is called when the stream is created
start(controller) {
// create a writable stream for writing data to test.txt
this.stream = fs.createWriteStream(destinationPath);
// handle errors on the stream
this.stream.on("error", err => {
// if an error occurs, abort the stream
controller.error(err);
this.stream.destroy();
});
},
// this method is called when a chunk of data is ready to be written
write(chunk) {
return new Promise((resolve, reject) => {
// write the chunk to the stream
console.log("chunk",chunk.length)
const ok = this.stream.write(chunk);
if (ok) {
// if the write succeeds, resolve the promise
resolve();
} else {
// if the write fails, wait for drain event and then resolve
this.stream.once("drain", resolve);
}
});
},
// this method is called when no more data will be written
close() {
return new Promise((resolve, reject) => {
// end the stream and resolve when it finishes
this.stream.end(resolve);
});
},
// this method is called when the stream is aborted
abort(err) {
// destroy the stream with an error
this.stream.destroy(err);
}
};
// create a queuing strategy object with highWaterMark of 1
const queuingStrategy = new CountQueuingStrategy({highWaterMark: 1});
// create a WritableStream with sink and queuingStrategy objects as arguments
const writableStream = new WritableStream(sink, queuingStrategy);
return writableStream
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
One more, I need your help. I have a problem with chunk size.
Encrypt From: https://pgpainless.readthedocs.io/en/latest/
Beta Was this translation helpful? Give feedback.
All reactions