Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
encryptionInfo.key.cipherAlgorithm,
encryptionInfo.key.cipherChaining,
verifierHashValueKey,
encryptionInfo.key.saltValue,
verifierHashValue
);
// Build the encryption info buffer
const encryptionInfoBuffer = this._buildEncryptionInfo(encryptionInfo);
// Create a new CFB
let output = cfb.utils.cfb_new();
// Add the encryption info and encrypted package
cfb.utils.cfb_add(output, "EncryptionInfo", encryptionInfoBuffer);
cfb.utils.cfb_add(output, "EncryptedPackage", encryptedPackage);
// Delete the SheetJS entry that is added at initialization
cfb.utils.cfb_del(output, "\u0001Sh33tJ5");
// Write to a buffer and return
output = cfb.write(output);
// The cfb library writes to a Uint8array in the browser. Convert to a Buffer.
if (!Buffer.isBuffer(output)) output = Buffer.from(output);
return output;
}
// Use the key to encrypt the hash value
encryptionInfo.key.encryptedVerifierHashValue = this._crypt(
true,
encryptionInfo.key.cipherAlgorithm,
encryptionInfo.key.cipherChaining,
verifierHashValueKey,
encryptionInfo.key.saltValue,
verifierHashValue
);
// Build the encryption info buffer
const encryptionInfoBuffer = this._buildEncryptionInfo(encryptionInfo);
// Create a new CFB
let output = cfb.utils.cfb_new();
// Add the encryption info and encrypted package
cfb.utils.cfb_add(output, "EncryptionInfo", encryptionInfoBuffer);
cfb.utils.cfb_add(output, "EncryptedPackage", encryptedPackage);
// Delete the SheetJS entry that is added at initialization
cfb.utils.cfb_del(output, "\u0001Sh33tJ5");
// Write to a buffer and return
output = cfb.write(output);
// The cfb library writes to a Uint8array in the browser. Convert to a Buffer.
if (!Buffer.isBuffer(output)) output = Buffer.from(output);
return output;
}
.option('-a, --append', 'add files to CFB (overwrite existing data)')
.option('-d, --delete', 'delete files from CFB')
.option('--dev', 'development mode')
.option('--read', 'read but do not print out contents');
program.parse(process.argv);
const exit = process.exit;
const die = (errno: number, msg: string) => { console.error(n + ": " + msg); exit(errno); };
const logit = (cmd: string, f: string) => { console.error(sprintf("%-6s %s", cmd, f)); };
if(program.args.length === 0) die(1, "must specify a filename");
if(program.create) {
logit("create", program.args[0]);
const newcfb = X.utils.cfb_new();
X.writeFile(newcfb, program.args[0]);
}
if(!fs.existsSync(program.args[0])) die(1, "must specify a filename");
const opts: X.CFB$ParsingOptions = {type:'file'};
if(program.dev) opts.WTF = true;
const cfb: X.CFB$Container = X.read(program.args[0], opts);
if(program.quiet) exit(0);
if(program.dump) {
console.log("Full Paths:");
console.log(cfb.FullPaths.map((x) => " " + x).join("\n"));
console.log("File Index:");
console.log(cfb.FileIndex);
program.args.slice(1).forEach((x: string) => {
logit("append", x);
X.utils.cfb_add(cfb, "/" + x, fs.readFileSync(x));
});
X.writeFile(cfb, program.args[0]);
program.args.slice(1).forEach((x: string) => {
logit("delete", x);
X.utils.cfb_del(cfb, "/" + x);
});
X.writeFile(cfb, program.args[0]);