npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

officecrypto-tool

v0.0.18

Published

officeCrypto is a library for node.js that can be used to decrypt and encrypt excel files.

Downloads

18,381

Readme

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 of MS office and WPS files, Support doc docx xls xlsx ppt pptx decryption, support xls decryption in BIFF8 and BIFF5 formats. 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

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

Now that the files referenced by the test use case have been modified to submodule dependencies, if you have not downloaded the submodule dependencies, execute the following command:

-> tests/

1: git submodule init
2: git submodule update

Then check to see if the test_files directory is already in the tests directory and if all the files in it are there.

With Jest:

pnpm i 
pnpm run test

Todo

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

Resources

In other languages