# nolze/msoffcrypto-tool architecture

> Architecture diagram of the GitHub repository nolze/msoffcrypto-tool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nolze/msoffcrypto-tool
- Repository: https://github.com/nolze/msoffcrypto-tool

## Overview

msoffcrypto-tool is a Python library and CLI for decrypting Office documents, with experimental OOXML encryption. The principal workflow identifies an input format, loads a password or key, verifies it where supported, and decrypts to a caller-provided output; the CLI also exposes encryption and encrypted-file testing. Format handlers implement OOXML and legacy Word, Excel, and PowerPoint processing, backed by shared parsing and scheme-specific cryptography. The README documents key options and supported schemes; unsampled handler details and some CLI wiring are not inferred.

Main entry points: [`msoffcrypto/format/xls97.py`](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/xls97.py) (Excel 97 handler), [`msoffcrypto/__init__.py`](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/__init__.py) (Format detection), [`msoffcrypto/format/ooxml.py`](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/ooxml.py) (OOXML handler), [`msoffcrypto/format/doc97.py`](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/doc97.py) (Word 97 handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI<br/>[__main__.py]"]
  node_factory["Format detection<br/>[__init__.py]"]
end

subgraph group_formats["Format handlers"]
  node_base["File interface<br/>[base.py]"]
  node_common["Header parsing<br/>[common.py]"]
  node_ooxml["OOXML handler<br/>[ooxml.py]"]
  node_doc["Word 97 handler<br/>[doc97.py]"]
  node_xls["Excel 97 handler<br/>[xls97.py]"]
  node_ppt["PowerPoint 97 handler<br/>[ppt97.py]"]
end

subgraph group_crypto["Cryptographic methods"]
  node_agile["Agile encryption<br/>[ecma376_agile.py]"]
  node_standard["Standard encryption"]
  node_extensible["Extensible encryption"]
  node_rc4["Office RC4<br/>[rc4.py]"]
  node_rc4api["RC4 CryptoAPI<br/>[rc4_cryptoapi.py]"]
  node_xor["XOR obfuscation<br/>[xor_obfuscation.py]"]
end

subgraph group_container["OOXML container"]
  node_encrypted_container["Encrypted OLE writer"]
end

node_user(("User or caller"))
node_output["Output file or buffer"]

node_user -->|"runs command"| node_cli
node_user -->|"opens file"| node_factory
node_cli -.->|"selects format"| node_factory
node_factory -->|"detects OOXML"| node_ooxml
node_factory -->|"detects Word"| node_doc
node_factory -->|"detects Excel"| node_xls
node_factory -->|"detects PowerPoint"| node_ppt
node_doc -->|"parses headers"| node_common
node_xls -->|"parses headers"| node_common
node_ppt -->|"parses headers"| node_common
node_ooxml -->|"uses scheme"| node_agile
node_ooxml -->|"uses scheme"| node_standard
node_doc -->|"uses cipher"| node_rc4
node_doc -->|"uses cipher"| node_rc4api
node_xls -->|"uses cipher"| node_rc4
node_xls -->|"uses cipher"| node_rc4api
node_xls -->|"uses method"| node_xor
node_ppt -->|"uses cipher"| node_rc4api
node_agile -->|"uses container"| node_encrypted_container
node_ooxml -->|"writes decrypted data"| node_output
node_ooxml -->|"writes encrypted data"| node_output
node_doc -->|"writes decrypted data"| node_output
node_xls -->|"writes decrypted data"| node_output
node_ppt -->|"writes decrypted data"| node_output

click node_cli "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/__main__.py"
click node_factory "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/__init__.py"
click node_base "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/base.py"
click node_common "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/common.py"
click node_ooxml "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/ooxml.py"
click node_doc "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/doc97.py"
click node_xls "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/xls97.py"
click node_ppt "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/ppt97.py"
click node_agile "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/ecma376_agile.py"
click node_standard "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/ecma376_standard.py"
click node_extensible "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/ecma376_extensible.py"
click node_rc4 "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/rc4.py"
click node_rc4api "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/rc4_cryptoapi.py"
click node_xor "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/xor_obfuscation.py"
click node_encrypted_container "https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/container/ecma376_encrypted.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_factory,node_user toneBlue
class node_base,node_common,node_ooxml,node_doc,node_xls,node_ppt toneAmber
class node_agile,node_standard,node_extensible,node_rc4,node_rc4api,node_xor toneMint
class node_encrypted_container toneRose
class node_output toneIndigo
```

## Components

### Entry points

- [CLI](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/__main__.py): `msoffcrypto/__main__.py`
- [Format detection](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/__init__.py): `msoffcrypto/__init__.py`

### Format handlers

- [File interface](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/base.py): `msoffcrypto/format/base.py`
- [Header parsing](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/common.py): `msoffcrypto/format/common.py`
- [OOXML handler](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/ooxml.py): `msoffcrypto/format/ooxml.py`
- [Word 97 handler](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/doc97.py): `msoffcrypto/format/doc97.py`
- [Excel 97 handler](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/xls97.py): `msoffcrypto/format/xls97.py`
- [PowerPoint 97 handler](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/format/ppt97.py): `msoffcrypto/format/ppt97.py`

### Cryptographic methods

- [Agile encryption](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/ecma376_agile.py): `msoffcrypto/method/ecma376_agile.py`
- [Standard encryption](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/ecma376_standard.py): `msoffcrypto/method/ecma376_standard.py`
- [Extensible encryption](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/ecma376_extensible.py): `msoffcrypto/method/ecma376_extensible.py`
- [Office RC4](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/rc4.py): `msoffcrypto/method/rc4.py`
- [RC4 CryptoAPI](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/rc4_cryptoapi.py): `msoffcrypto/method/rc4_cryptoapi.py`
- [XOR obfuscation](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/xor_obfuscation.py): `msoffcrypto/method/xor_obfuscation.py`

### OOXML container

- [Encrypted OLE writer](https://github.com/nolze/msoffcrypto-tool/blob/master/msoffcrypto/method/container/ecma376_encrypted.py): `msoffcrypto/method/container/ecma376_encrypted.py`

### Other components

- **User or caller**
- **Output file or buffer**

## Connections

- User or caller → CLI: runs command (evidence: `README.md`)
- User or caller → Format detection: opens file (evidence: `README.md`)
- CLI → Format detection: selects format
- Format detection → OOXML handler: detects OOXML (evidence: `msoffcrypto/__init__.py`)
- Format detection → Word 97 handler: detects Word (evidence: `msoffcrypto/__init__.py`)
- Format detection → Excel 97 handler: detects Excel (evidence: `msoffcrypto/__init__.py`)
- Format detection → PowerPoint 97 handler: detects PowerPoint (evidence: `msoffcrypto/__init__.py`)
- Word 97 handler → Header parsing: parses headers (evidence: `msoffcrypto/format/doc97.py`)
- Excel 97 handler → Header parsing: parses headers (evidence: `msoffcrypto/format/xls97.py`)
- PowerPoint 97 handler → Header parsing: parses headers (evidence: `msoffcrypto/format/ppt97.py`)
- OOXML handler → Agile encryption: uses scheme (evidence: `msoffcrypto/format/ooxml.py`)
- OOXML handler → Standard encryption: uses scheme (evidence: `msoffcrypto/format/ooxml.py`)
- Word 97 handler → Office RC4: uses cipher (evidence: `msoffcrypto/format/doc97.py`)
- Word 97 handler → RC4 CryptoAPI: uses cipher (evidence: `msoffcrypto/format/doc97.py`)
- Excel 97 handler → Office RC4: uses cipher (evidence: `msoffcrypto/format/xls97.py`)
- Excel 97 handler → RC4 CryptoAPI: uses cipher (evidence: `msoffcrypto/format/xls97.py`)
- Excel 97 handler → XOR obfuscation: uses method (evidence: `msoffcrypto/format/xls97.py`)
- PowerPoint 97 handler → RC4 CryptoAPI: uses cipher (evidence: `msoffcrypto/format/ppt97.py`)
- Agile encryption → Encrypted OLE writer: uses container (evidence: `msoffcrypto/method/ecma376_agile.py`)
- OOXML handler → Output file or buffer: writes decrypted data (evidence: `README.md`)
- OOXML handler → Output file or buffer: writes encrypted data (evidence: `README.md`)
- Word 97 handler → Output file or buffer: writes decrypted data (evidence: `README.md`)
- Excel 97 handler → Output file or buffer: writes decrypted data (evidence: `README.md`)
- PowerPoint 97 handler → Output file or buffer: writes decrypted data (evidence: `README.md`)
