I'm using nodejs built-in crypto, zlib and fs package to encrypt a large file using these codes.
import fs from 'fs';
import zlib from 'zlib';
import crypto from 'crypto';
const initVect = crypto.randomBytes(16);
const fread = fs.createReadStream('X:/File.mp4');
const fwrite = fs.createWriteStream('X:/File.mp4.enc');
const gzipStream = zlib.createGzip();
const hashedPassword = crypto.createHash('sha256').update('SomePassword').digest();
const cipher = crypto.createCipheriv(
'aes-256-cbc',
hashedPassword,
initVect
);
fread.pipe(gzipStream).pipe(cipher).pipe(fwrite);
But I don't know how to add an encryption progress/status indicator, since a large file will take a lot of time to encrypt I want to show encryption progress to the user in the console.
Can you guys tell me how to achieve this?