How rusconn/rpgmvmz-decrypter works
Project Type and Purpose
• This is an open-source command-line tool written in Rust for decrypting encrypted assets in RPG Maker MV/MZ games.
• It has a two-crate layout:
• A binary crate (cli/) implementing the CLI interface and argument parsing.
• A library crate (lib/) containing the core decryption logic.
High-Level File-Structure Analysis
• Top level:
• Cargo.toml / Cargo.lock – workspace / dependency management.
• cli/ – binary crate: main.rs, config.rs, error.rs, system_json.rs.
• lib/ – library crate: lib.rs with the decrypter implementation.
• rust-toolchain.toml, rustfmt.toml, .gitignore, README.md, LICENSE.
• No external web services, databases or UI layers—it's purely file-system oriented.
README Insights
• The tool is installed via Cargo and invoked as decvz <game_dir>.
• It scans the input directory, decrypts files matching certain extensions, and writes a _decrypted output tree.
• Decryption rules map encrypted extensions (.rpgmvo, .rpgmvp, etc.) to standard ones (.ogg, .png, etc.).
Main Components
a. CLI Frontend (binary crate)
• Argument Parser (main.rs)
• Configuration Loader (config.rs)
• System JSON Inspector (system_json.rs) – discovers RPG Maker’s System.json or asset manifest
• Error Handling (error.rs)
b. Decryption Core (library crate)
• File Scanner & Matcher – finds all files matching encrypted extensions
• Decryption Algorithms – byte-level transformation logic
• File Writer – writes decrypted files to <game_dir>_decrypted
c. File System
• Input Game Directory
• Output Decrypted Directory
Relationships & Data Flow
1. User invokes decvz <game_dir>.
2. Main reads CLI args → loads configuration.
3. System JSON Inspector locates metadata (optional).
4. Decryption Core is called with the list of encrypted files.
5. Core reads each file, applies the rule‐based decryption, and writes the result to the output directory.
6. Errors bubble up via the error module back to the CLI for reporting.
Architectural Patterns & Principles
• Modular separation: CLI concerns vs. pure-logic library.
• Single Responsibility: each Rust module has a clear domain.
• Pluggable rules: decryption mappings are data-driven and could be extended in the library.
Key Details to Capture
• Separation of concerns (binary vs. library).
• Data-driven decryption rules.
• End-to-end file scanning → decrypt → write workflow.
• Error propagation path.