Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ZipCryptoStream.prototype._smartStream = function(ae, callback) {
var zipCrypto = new ZipCrypto(this.options);
zipCrypto.init();
var encryptionHeader = Buffer.from(cryptoRandomString(24), 'hex');
var encryptedHeader = zipCrypto.encrypt(encryptionHeader);
var crc = ae.getTimeDos();
encryptedHeader[10] = crc & 0xff;
encryptedHeader[11] = (crc >> 8) & 0xff;
zipCrypto.init();
var encryptedHeader2 = zipCrypto.encrypt(encryptedHeader);
this.write(encryptedHeader2);
var deflate = ae.getMethod() === constants.METHOD_DEFLATED;
var process = deflate
? new DeflateCRC32Stream(this.options.zlib)
: new CRC32Stream();
var error = null;
function handleStuff() {
var digest = process.digest().readUInt32BE(0);
ae.setCrc(digest);
ae.setSize(process.size());
ae.setCompressedSize(process.size(true) + encryptionHeader.length);
this._afterAppend(ae);
callback(error, ae);
}
var outStream = new Writable({
write: function(chunk, encoding, callback) {
var buffer = zipCrypto.encrypt(chunk);
this.write(buffer);
callback();
}.bind(this)