Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const ZipCrypto = function (options = {}) {
if (!options.password) {
throw new Error('options.password is required');
}
if (!Buffer.isBuffer(options.password)) {
options.password = Buffer.from(options.password, 'utf-8');
}
if (!(this instanceof ZipCrypto)) {
return new ZipCrypto(options);
}
Zip.call(this, options);
this.engine = new ZipCryptoStream(this.options);
};
inherits(ZipCrypto, Zip);
const ZipEncrypted = function (options = {}) {
if (!options.password) {
throw new Error('options.password is required');
}
if (!Buffer.isBuffer(options.password)) {
options.password = Buffer.from(options.password, 'utf-8');
}
if (!(this instanceof ZipEncrypted)) {
return new ZipEncrypted(options);
}
Zip.call(this, options);
switch (options.encryptionMethod) {
case 'aes256': this.engine = new ZipAesStream(options); break;
case 'zip20': this.engine = new ZipCryptoStream(options); break;
default: throw new Error(`Unsupported encryption method: '${options.encryptionMethod}'. Please use either 'aes256' or 'zip20'.`);
}
};
inherits(ZipEncrypted, Zip);