Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

officecrypto-tool

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

officecrypto-tool - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

src/util/ppt97.js

25

index.js

@@ -11,4 +11,4 @@ /* eslint-disable valid-jsdoc */

const doc97File = require('./src/util/doc97');
const ppt97File = require('./src/util/ppt97');
/**

@@ -80,2 +80,8 @@ *

const PowerPointBook = CFB.find(cfb, 'PowerPoint Document');
if (PowerPointBook) {
output = ppt97File.decrypt(cfb, PowerPointBook.content, password, input);
return output;
}
if (!encryptionInfo) return input; // Not encrypted returns directly to the original buffer

@@ -159,2 +165,19 @@

const PowerPointBook = CFB.find(cfb, 'PowerPoint Document');
if (PowerPointBook) {
let blob = PowerPointBook.content;
if (!Buffer.isBuffer(blob)) blob = Buffer.from(blob);
const CurrentUser = CFB.find(cfb, 'Current User');
let currentUserBlob = CurrentUser.content;
if (!Buffer.isBuffer(currentUserBlob)) currentUserBlob = Buffer.from(currentUserBlob);
const currentUser = ppt97File.parseCurrentUser(currentUserBlob);
blob.l = currentUser.currentUserAtom.offsetToCurrentEdit;
const userEditAtom = ppt97File.parseUserEditAtom(blob);
if (userEditAtom.rh.recLen === 0x00000020) {
return true;
}
}
return false;

@@ -161,0 +184,0 @@ }

2

package.json
{
"name": "officecrypto-tool",
"version": "0.0.7",
"version": "0.0.8",
"description": "officeCrypto is a library for node.js that can be used to decrypt and encrypt excel files.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -9,3 +9,3 @@ # officecrypto-tool

Now it supports encryption and decryption of` MS office and WPS files`, Support doc docx xls xlsx pptx decryption, support docx xlsx pptx encryption.
Now it supports encryption and decryption of` MS office and WPS files`, Support `doc docx xls xlsx ppt pptx` decryption, support `docx xlsx pptx` encryption.

@@ -77,3 +77,3 @@ ## Contents

* [x] MS-XLS (Excel 2002, 2003, 2004) (experimental)
* [] MS-PPT (PowerPoint 2002, 2003, 2004) (partial, experimental)
* [x] MS-PPT (PowerPoint 2002, 2003, 2004) (partial, experimental)
* [x] Office Binary Document RC4

@@ -80,0 +80,0 @@ * [x] MS-DOC (Word 97, 98, 2000)

@@ -42,6 +42,5 @@ /* eslint-disable valid-jsdoc */

*/
exports.decrypt = function decrypt(password, salt, KeySize, input, blocksize = 0x200) {
exports.decrypt = function decrypt(password, salt, KeySize, input, blocksize = 0x200, block = 0) {
let start = 0;
let end = 0;
let block = 0;
let key = convertPasswordToKey(password, salt, KeySize, block);

@@ -48,0 +47,0 @@

@@ -11,5 +11,14 @@

const input = await fs.readFile(`${filePath}/xor_pass_length_5_test.xls`);
const output = await officeCrypto.decrypt(input, {password: 'xxxxx'});
await fs.writeFile(`${filePath}/xor_pass_length_5_out_success.xls`, output);
// const input = await fs.readFile(`${filePath}/xor_pass_length_5_test.xls`);
// const output = await officeCrypto.decrypt(input, {password: 'xxxxx'});
// await fs.writeFile(`${filePath}/xor_pass_length_5_out_success.xls`, output);
// const input = await fs.readFile(`${filePath}/rc4_pass.ppt`);
// const output = await officeCrypto.decrypt(input, {password: '123456'});
// await fs.writeFile(`${filePath}/rc4_out_success.ppt`, output);
// const input = await fs.readFile(`${filePath}/rc4_pass.ppt`);
const input = await fs.readFile(`${filePath}/rc4_out_success.ppt`);
const isEncrypted = officeCrypto.isEncrypted(input);
console.log('isEncrypted-->', isEncrypted);
})();

@@ -25,2 +25,9 @@

it('decrypt ppt success', async () => {
const input = await fs.readFile(`${filePath}/rc4_pass.ppt`);
const output = await officeCrypto.decrypt(input, {password: '123456'});
await fs.writeFile(`${filePath}/rc4_out_success.ppt`, output);
// expect(200).toEqual(200);
});
it('decrypt unencrypted doc success', async () => {

@@ -56,2 +63,13 @@ const input = await fs.readFile(`${encryptFilePath}/doc_wait_for_encrypt.doc`);

});
it('decrypt rc4_crypto_api ppt, the password is incorrect', async () => {
const test = function test() {
return async function() {
const input = await fs.readFile(`${filePath}/rc4_pass.ppt`);
const output = await officeCrypto.decrypt(input, {password: 'xxxxx'});
};
};
await expect(test()).rejects.toThrowError(new Error( `The password is incorrect` ));
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc