msoffcrypto-tool is a Python library and command-line tool for decrypting and encrypting MS Office files (e.g., .doc, .xls, .ppt, .docx, .xlsx, .pptx) that are protected with a password or other keys. The current version is 6.0.0, released in February 2024. Releases are infrequent but active, addressing security updates and Python version compatibility.
pip install msoffcrypto-toolVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core API for decrypting an MS Office file. It uses an in-memory byte stream to simulate file I/O. Remember to replace the `encrypted_content` with actual data from a real encrypted file for functional decryption. It also shows handling common decryption exceptions.
Upgrade your Python environment to 3.10 or newer, or pin msoffcrypto-tool to a version < 6.0.0 if legacy Python is unavoidable (e.g., `pip install msoffcrypto-tool<6.0`).
Install the library with the `[all]` extra to include all optional dependencies: `pip install msoffcrypto-tool[all]`.
Always test with your specific file types. Refer to the GitHub repository's issue tracker or documentation for details on supported formats and limitations.
Install the library using pip: `pip install msoffcrypto-tool`.
Verify that the password used with `file.load_key(password='your_password')` is the correct one for the encrypted file. Double-check for typos or case sensitivity.
Ensure the file is a valid and supported Microsoft Office document and that it is indeed password-protected. Try opening the file manually with the password to confirm its integrity and encryption status. If the file is a very old or very new/uncommon encryption type, it might not be supported by the current version of the library.