pub struct Decrypter<'a> { /* private fields */ }Expand description
A struct responsible for decrypting and extracting files from encrypted game archives.
Implementations§
Source§impl<'a> Decrypter<'a>
impl<'a> Decrypter<'a>
Sourcepub fn decrypt(
&mut self,
archive_data: &'a [u8],
) -> Result<Vec<ArchiveEntry>, ExtractError>
pub fn decrypt( &mut self, archive_data: &'a [u8], ) -> Result<Vec<ArchiveEntry>, ExtractError>
Returns Vec of decrypted ArchiveEntry entries.
§Parameters
archive_data: The content of the archive file.
§Returns
Vec<ArchiveEntry>if files were successfully decrypted.ExtractErrorotherwise.
§Errors
ExtractError::InvalidHeaderfor invalid header.ExtractError::InvalidEnginefor invalid header engine type byte.
§Example
use rpgmad_lib::Decrypter;
use std::{path::PathBuf, fs::{read, write, create_dir_all}};
let data = read("C:/Game/Game.rgss3a").unwrap();
let decrypted_entries = Decrypter::new().decrypt(&data).unwrap();
for entry in decrypted_entries {
let path = String::from_utf8_lossy(&entry.path);
let output_path = PathBuf::from("C:/Game").join(path.as_ref());
if let Some(parent) = output_path.parent() {
create_dir_all(parent).unwrap();
}
write(output_path, entry.data).unwrap();
}Sourcepub fn encrypt(
&mut self,
archive_entries: &[ArchiveEntry],
engine: Engine,
) -> Vec<u8> ⓘ
pub fn encrypt( &mut self, archive_entries: &[ArchiveEntry], engine: Engine, ) -> Vec<u8> ⓘ
Returns encrypted archive data as Vec<u8>.
§Parameters
entries: Archive entries to encrypt.engine: Target archive engine.
§Returns
Vec<u8>representing encrypted archive data.
§Example
use rpgmad_lib::{Decrypter, Engine, ArchiveEntry};
use std::{fs::{read, write}, borrow::Cow};
let archive_entries = [ArchiveEntry {
path: Cow::Borrowed(b"Graphics/Tilesets/Tileset1.png"),
data: read("Graphics/Tilesets/Tileset1.png").unwrap()
}];
let archive_data = Decrypter::new().encrypt(&archive_entries, Engine::VXAce);
write("./Game.rgss3a", archive_data).unwrap();Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Decrypter<'a>
impl<'a> RefUnwindSafe for Decrypter<'a>
impl<'a> Send for Decrypter<'a>
impl<'a> Sync for Decrypter<'a>
impl<'a> Unpin for Decrypter<'a>
impl<'a> UnwindSafe for Decrypter<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more