|
1 | 1 | # rpgm-archive-decrypter-lib |
2 | 2 |
|
3 | | -Library for decrypting RPG Maker `rgss` archives. |
| 3 | +**BLAZINGLY** :fire: fast and tiny library for decrypting RPG Maker XP/VX/VXAce `.rgssad`/`.rgss2a`/`.rgss3a` archives. |
4 | 4 |
|
5 | | -Used in [rpgm-archive-decrypter](https://github.com/savannstm/rpgm-archive-decrypter). |
| 5 | +This project essentially is a rewrite of uuksu's [RPGMakerDecrypter](https://github.com/uuksu/RPGMakerDecrypter) in Rust as a library, but it also implements archive encryption. |
| 6 | + |
| 7 | +And since it's implemented in Rust 🦀🦀🦀, it's also very tiny, clean, and performant. |
| 8 | + |
| 9 | +Used in my [rpgm-archive-decrypter](https://github.com/savannstm/rpgm-archive-decrypter) CLI tool. |
6 | 10 |
|
7 | 11 | ## Example |
8 | 12 |
|
9 | | -```rust |
| 13 | +### Decrypt |
| 14 | + |
| 15 | +```rust no_run |
10 | 16 | use rpgmad_lib::{Decrypter, decrypt_archive}; |
11 | | -use std::path::PathBuf; |
| 17 | +use std::{path::PathBuf, fs::{read, write, create_dir_all}}; |
12 | 18 |
|
13 | | -let archive_content: Vec<u8> = std::fs::read("C:/Game/Game.rgss3a").unwrap(); |
| 19 | +let archive_content: Vec<u8> = read("C:/Game/Game.rgss3a").unwrap(); |
14 | 20 |
|
15 | 21 | // Using Decrypter struct |
16 | 22 | let mut decrypter = Decrypter::new(); |
17 | | -let decrypted_files = decrypter.decrypt(&archive_content).unwrap(); |
| 23 | +let decrypted_entries = decrypter.decrypt(&archive_content).unwrap(); |
18 | 24 |
|
19 | 25 | // Using function |
20 | | -let decrypted_files = decrypt_archive(&archive_content).unwrap(); |
| 26 | +let decrypted_entries = decrypt_archive(&archive_content).unwrap(); |
21 | 27 |
|
22 | | -for file in decrypted_files { |
23 | | - let path = String::from_utf8_lossy(&file.path); |
| 28 | +for entry in decrypted_entries { |
| 29 | + let path = String::from_utf8_lossy(&entry.path); |
24 | 30 | let output_path = PathBuf::from("C:/Game").join(path.as_ref()); |
25 | 31 |
|
26 | 32 | if let Some(parent) = output_path.parent() { |
27 | | - std::fs::create_dir_all(parent).unwrap(); |
| 33 | + create_dir_all(parent).unwrap(); |
28 | 34 | } |
29 | 35 |
|
30 | | - std::fs::write(output_path, file.content).unwrap(); |
| 36 | + write(output_path, entry.data).unwrap(); |
31 | 37 | } |
32 | 38 | ``` |
33 | 39 |
|
| 40 | +### Encrypt |
| 41 | + |
| 42 | +```rust no_run |
| 43 | +use rpgmad_lib::{Decrypter, encrypt_archive, ArchiveEntry, Engine}; |
| 44 | +use std::{fs::{read, write}, borrow::Cow}; |
| 45 | + |
| 46 | +let archive_entries = [ArchiveEntry { |
| 47 | + path: Cow::Borrowed(b"Graphics/Tilesets/Tileset1.png"), |
| 48 | + data: read("Graphics/Tilesets/Tileset1.png").unwrap() |
| 49 | +}]; |
| 50 | + |
| 51 | +// Using Decrypter struct |
| 52 | +let mut decrypter = Decrypter::new(); |
| 53 | +let archive_data = decrypter.encrypt(&archive_entries, Engine::VXAce); |
| 54 | + |
| 55 | +// Using function |
| 56 | +let archive_data = encrypt_archive(&archive_entries, Engine::VXAce); |
| 57 | + |
| 58 | +write("./Game.rgss3a", archive_data).unwrap(); |
| 59 | +``` |
| 60 | + |
34 | 61 | ## License |
35 | 62 |
|
36 | 63 | Project is licensed under WTFPL. |
0 commit comments