0.0.12 • Published 2 months ago

officecrypto-tool v0.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

officecrypto-tool

officecrypto-tool is a library for js that can be used to decrypt and encrypt office(excel/ppt/word) files..

Special Notes

The implementation of this library refers to xlsx and xlsx-populate, especially xlsx-populate, part of the source code reference and directly copied over.

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

Contents

Install

npm/yarn/pnpm install officecrypto-tool

Examples

const officeCrypto = require('officecrypto-tool');
const fs = require('fs').promises;

//decrypt a file with a password
(async ()=>{
        const input = await fs.readFile(`pass_test.xlsx`);
        const output = await officeCrypto.decrypt(input, {password: '123456'});
        await fs.writeFile(`out_success.xlsx`, output);
})()

//Setting up encrypted files with passwords
(async ()=>{
        const input = await fs.readFile(`test.xlsx`);
        const output = officeCrypto.encrypt(input, {password: '123456'});
        await fs.writeFile(`standard_out_success.xlsx`, output);
})()

//Determine whether excel file is encrypted or not, support xls and xlsx format, encrypted is true, not encrypted is false.
(async ()=>{
        const input = await fs.readFile(`encrypted_test.xlsx`);
        const isEncrypted = officeCrypto.isEncrypted(input);
        // output: true

        const input1 = await fs.readFile(`not_encrypted_test.xlsx`);
        const isEncrypted1 = officeCrypto.isEncrypted(input1);
        // output: false
})()

Supported encryption methods

OFFICECRYPTO specs

  • ECMA-376 (Agile Encryption/Standard Encryption)
    • MS-DOCX (OOXML) (Word 2007-2016)
    • MS-XLSX (OOXML) (Excel 2007-2016)
    • MS-PPTX (OOXML) (PowerPoint 2007-2016)
  • Office Binary Document RC4 CryptoAPI
    • MS-DOC (Word 2002, 2003, 2004)
    • MS-XLS (Excel 2002, 2003, 2004) (experimental)
    • MS-PPT (PowerPoint 2002, 2003, 2004) (partial, experimental)
  • Office Binary Document RC4
    • MS-DOC (Word 97, 98, 2000)
    • MS-XLS (Excel 97, 98, 2000) (experimental)
  • XOR Obfuscation
    • MS-XLS
    • [] MS-DOC
  • ECMA-376 (Extensible Encryption)

Other

  • Word 95 Encryption And Decryption (Word 95 and prior)
  • Excel 95 Encryption And Decryption (Excel 95 and prior)
  • PowerPoint 95 Encryption And Decryption (PowerPoint 95 and prior)

PRs are welcome!

Tests

With Jest:

pnpm i 
pnpm run test

Todo

  • Add tests
  • Support decryption and encryption with passwords
  • Support older encryption schemes
  • Add decryption tests for various file formats
  • Support frontend
  • Support more encryption and decrytion

Resources

In other languages

0.0.12

2 months ago

0.0.11

2 months ago

0.0.10

3 months ago

0.0.9

4 months ago

0.0.8

7 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

12 months ago

0.0.1

12 months ago