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, data: &'a [u8], ) -> Result<Vec<DecryptedFile>, ExtractError>

Returns Vec of decrypted files.

§Parameters
  • data: The content of the archive file.
§Returns
  • Ok(Vec<DecryptedFile>) if files were successfully decrypted.
  • Err(ExtractError::InvalidHeader) for invalid header.
  • Err(ExtractError::InvalidEngine) for invalid header engine type byte.
§Example
use rpgmad_lib::Decrypter;
use std::path::PathBuf;

let data: Vec<u8> = std::fs::read("C:/Game/Game.rgss3a").unwrap();
let decrypted_files = Decrypter::new().decrypt(&data).unwrap();

for file in decrypted_files {
    let path = String::from_utf8_lossy(&file.path);
    let output_path = PathBuf::from("C:/Game").join(path.as_ref());

    if let Some(parent) = output_path.parent() {
        std::fs::create_dir_all(parent).unwrap();
    }

    std::fs::write(output_path, file.content).unwrap();
}

Trait Implementations§

Source§

impl<'a> Default for Decrypter<'a>

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.