How to use the cfb.utils function in cfb

To help you get started, we’ve selected a few cfb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dtjohnson / xlsx-populate / lib / Encryptor.js View on Github external
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;
    }
github dtjohnson / xlsx-populate / lib / Encryptor.js View on Github external
// 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;
    }
github SheetJS / js-cfb / types / bin_cfb.ts View on Github external
.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);
github SheetJS / js-cfb / types / bin_cfb.ts View on Github external
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]);
github SheetJS / js-cfb / types / bin_cfb.ts View on Github external
program.args.slice(1).forEach((x: string) => {
		logit("delete", x);
		X.utils.cfb_del(cfb, "/" + x);
	});
	X.writeFile(cfb, program.args[0]);

cfb

Compound File Binary File Format extractor

Apache-2.0
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis