CLI tool
nolze/msoffcrypto-tool avatar
nolze/msoffcrypto-tool

msoffcrypto-tool handles the Office file encryption formats Python libraries usually skip

Python tool and library for decrypting and encrypting MS Office files using passwords or other keys

627 stars92 forksPythonMIT

At a glance

What is it?
msoffcrypto-tool is a Python command line tool and library for decrypting and encrypting MS Office documents with a password or a key. It covers the modern OOXML encryption schemes as well as several older binary formats, and it marks the gaps clearly.
Who is it for?
msoffcrypto-tool fits automation that has to open password protected spreadsheets in bulk, or a pipeline that needs to write encrypted OOXML documents from a template. It does not fit a job that needs every legacy Office format, because the support matrix marks several of them experimental or partial and leaves Word 95 encryption and ECMA-376 Extensible Encryption unimplemented.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 12 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

One package for the Office encryption formats

msoffcrypto-tool is described as a Python tool and library for decrypting and encrypting MS Office files using a password or other keys. That is a narrower statement than it sounds, because Office has accumulated several incompatible protection schemes over the years, from the modern OOXML containers of Word 2007 onwards back to the binary formats of the 1990s, and each one keeps its credentials in a different place. A pipeline that has to read a spreadsheet from a partner organisation cannot assume the file is one particular flavour of encrypted. The package is published on PyPI, carries an MIT licence, keeps its documentation on readthedocs, and the project version in pyproject.toml is 6.0.0. The repository is laid out as a normal Python package, with the code in the msoffcrypto directory, the test suite in tests, the documentation in docs, and poetry.lock and pyproject.toml for dependency management.

The command line covers the three common jobs

Installation is a single pip command, and the command line itself is small enough to learn in a minute.

bash
pip install msoffcrypto-tool

Decryption takes an input file, an output file and the password, with the -p flag.

bash
msoffcrypto-tool encrypted.docx decrypted.docx -p Passw0rd

If you leave the password value off, the tool prompts for it, which is the safer habit on a shared machine since the password never appears in your shell history.

bash
$ msoffcrypto-tool encrypted.docx decrypted.docx -p
Password:

The third command answers the question you should ask before anything else, whether a file is encrypted at all, and it is also what a script can branch on because the exit status reports it: 1 for an encrypted file and 0 for one that is not.

bash
msoffcrypto-tool document.doc --test -v

Library use goes through OfficeFile and load_key

The library API exists for the cases a shell script cannot cover, starting with piping an encrypted file straight into a parser.

python
import msoffcrypto

encrypted = open("encrypted.docx", "rb")
file = msoffcrypto.OfficeFile(encrypted)

file.load_key(password="Passw0rd")  # Use password

with open("decrypted.docx", "wb") as f:
    file.decrypt(f)

encrypted.close()

The OfficeFile constructor sniffs the container and the encryption scheme, load_key supplies the credential, and decrypt writes the plain file out. Nothing is written to disk in between, so the same pattern works with a spreadsheet that goes straight into a dataframe.

python
import msoffcrypto
import io
import pandas as pd

decrypted = io.BytesIO()

with open("encrypted.xlsx", "rb") as f:
    file = msoffcrypto.OfficeFile(f)
    file.load_key(password="Passw0rd")  # Use password
    file.decrypt(decrypted)

df = pd.read_excel(decrypted)
print(df)

Keys are not only passwords, and you can check them first

The advanced usage in the documentation shows the options that matter for automation. Verification before decryption is one of them. The ECMA-376 Agile and Standard crypto systems let a caller know whether the supplied password is correct before actually decrypting the file, and the verify_password option exposes that, with the documentation noting that it is currently only meaningful for ECMA-376 Agile and Standard Encryption. A second option, verify_integrity, checks the HMAC of the data payload before decryption, and that one is documented as meaningful only for ECMA-376 Agile Encryption. Three key types are supported: passwords, intermediate keys passed as secret_key, and private keys used for generating escrow keys, passed as private_key. The reference the project points to for these key types is a paper on backdooring MS Office documents with secret master keys, which explains where escrow keys fit into the scheme. The three calls look like this.

python
file.load_key(password="Passw0rd", verify_password=True)

# Use private key
file.load_key(private_key=open("priv.pem", "rb"))

# Use intermediate key (secretKey)
file.load_key(secret_key=binascii.unhexlify("AE8C36E68B4BB9EA46E5544A5FDB6693875B2FDE1507CBC65C8BCF99E25C2562"))

The support matrix tells you where the edges are

The README keeps an explicit table of what is implemented, and it is the most useful part of the page. Under the MS-OFFCRYPTO specifications, ECMA-376 Agile and Standard Encryption are supported for MS-DOCX, MS-XLSX and MS-PPTX, which covers Word, Excel and PowerPoint from 2007 onwards. Office Binary Document RC4 CryptoAPI covers MS-DOC from Word 2002, 2003 and 2004, MS-XLS for Excel 2002 through 2010 marked experimental, and MS-PPT for PowerPoint 2002 through 2004 marked partial and experimental. Office Binary Document RC4 covers Word 97, 98 and 2000 and Excel 97, 98 and 2000, the latter experimental. XOR Obfuscation is supported for Excel 2002 and 2003 and is not supported for MS-DOC. ECMA-376 Extensible Encryption is unchecked, and so are Word 95, Excel 95 and PowerPoint 95 encryption. A tool that tells you which rows are ticked and which are not saves a lot of guessing.

Writing encrypted files is OOXML only and experimental

The encryption side of the project is narrower than the decryption side, and the README says so twice. The encryption feature is labelled experimental and to be used at your own risk, and it applies to OOXML only, which means the Word, Excel and PowerPoint formats from 2007 onwards rather than the binary documents. On the command line, the -e flag with a -p flag turns a plain document into a password protected one. In the library, the entry point is the OOXMLFile class from the ooxml format module rather than the generic OfficeFile, and the encrypt method takes the password and the output stream. The in-memory example shows the intended use, building a buffer that contains an OLE container with an encrypted stream, which is the form a service would want when it never writes the plain file to disk.

python
from msoffcrypto.format.ooxml import OOXMLFile

plain = open("plain.docx", "rb")
file = OOXMLFile(plain)

with open("encrypted.docx", "wb") as f:
    file.encrypt("Passw0rd", f)

plain.close()

MIT licensed, tested with poetry, with an honest roadmap

The project is MIT licensed and ships a NOTICE.txt alongside the LICENSE.txt. Tests run with coverage and pytest through poetry, so a contributor clones the repository, installs the environment and runs the suite. The README also carries a todo list, which is unusually useful for judging the project's direction. Finished items include the password prompt mode for the CLI, the API documents, publication to PyPI, support for older encryption schemes, function level tests and OOXML encryption. Still open are type hints, support for other encryption schemes, isolating the parser, and a redesign of the APIs tagged for version 6.0.0, which is worth noting because the current project version is already 6.0.0. There are no GitHub releases to speak of, so the changelog file in the repository is the version history, and the last push was on 2026-10-11.

Editorial conclusion

msoffcrypto-tool fits automation that has to open password protected spreadsheets in bulk, or a pipeline that needs to write encrypted OOXML documents from a template. It does not fit a job that needs every legacy Office format, because the support matrix marks several of them experimental or partial and leaves Word 95 encryption and ECMA-376 Extensible Encryption unimplemented. Before you depend on it, run msoffcrypto-tool document.doc --test -v on your files to see whether they are encrypted at all, and check which scheme each file uses before trusting the decrypt path.

Frequently asked questions

How do I install msoffcrypto-tool?

The documented install is pip install msoffcrypto-tool. The project publishes on PyPI under the name msoffcrypto-tool and keeps its documentation on readthedocs.

How can I check whether an Office file is encrypted?

Use the test flag on the command line, for example msoffcrypto-tool document.doc --test -v. The tool returns 1 if the file is encrypted and 0 if it is not.

Which Office file formats can msoffcrypto-tool decrypt?

ECMA-376 Agile and Standard Encryption for Word, Excel and PowerPoint from 2007 onwards, plus older binary formats including Office Binary Document RC4 and RC4 CryptoAPI, with some of the older ones marked experimental or partial. ECMA-376 Extensible Encryption and the 95 era formats are not implemented.

Can msoffcrypto-tool create encrypted Office files?

Yes for OOXML only, and the project labels the encryption feature experimental and to be used at your own risk. On the command line you use the -e flag together with -p, and in the library you use the OOXMLFile class from msoffcrypto.format.ooxml.

Official sources

  1. Issues
  2. License: MIT
  3. nolze/msoffcrypto-tool on GitHub
  4. Project website
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/nolze-msoffcrypto-tool.svg)](https://hysenlabs.com/projects/nolze-msoffcrypto-tool)

Was this useful?