How to use the cfb.parse 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
decryptAsync(data, password) {
        // Parse the CFB input and pull out the encryption info and encrypted package entries.
        const parsed = cfb.parse(data);
        let encryptionInfoBuffer = _.find(parsed.FileIndex, { name: "EncryptionInfo" }).content;
        let encryptedPackageBuffer = _.find(parsed.FileIndex, { name: "EncryptedPackage" }).content;

        // In the browser the CFB content is an array. Convert to a Buffer.
        if (!Buffer.isBuffer(encryptionInfoBuffer)) encryptionInfoBuffer = Buffer.from(encryptionInfoBuffer);
        if (!Buffer.isBuffer(encryptedPackageBuffer)) encryptedPackageBuffer = Buffer.from(encryptedPackageBuffer);

        return externals.Promise.resolve()
            .then(() => this._parseEncryptionInfoAsync(encryptionInfoBuffer)) // Parse the encryption info XML into an object
            .then(encryptionInfo => {
                // Convert the password into an encryption key
                const key = this._convertPasswordToKey(
                    password,
                    encryptionInfo.key.hashAlgorithm,
                    encryptionInfo.key.saltValue,
                    encryptionInfo.key.spinCount,
github lalalic / docx4js / src / openxml / ole.js View on Github external
export function parse(data){
	let ole=OLE.parse(data)
	let content=ole.find("!ole10Native").content
	let start=content.slice(0,Math.min(content.length/2,512)).lastIndexOf(0)+1
	let end=content.indexOf(0,Math.min(start,content.length/2))-1
	return new TextDecoder("utf-8").decode(new Uint8Array(content.slice(start,end)))
}

cfb

Compound File Binary File Format extractor

Apache-2.0
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis