Decrypter

Struct Decrypter 

Source
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>

Source

pub fn new() -> Self

Creates a new Decrypter with empty buffer.

Source

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
§Errors
§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();
}
Source

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§

Source§

impl Default for Decrypter<'_>

Source§

fn default() -> Self

Returns a new Decrypter with default parameters.

Equivalent to calling Decrypter::new.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.