Struct Decrypter

Source
pub struct Decrypter { /* private fields */ }

Implementations§

Source§

impl Decrypter

Source

pub fn new() -> Self

Creates a new Decrypter instance.

Decrypter requires a key, which you can set from set_key_from_str() and set_key_from_image() functions. You can get the key string from encryptionKey field in System.json file to set from string, or from any rpgmvp/png_ image.

decrypt() function will try to determine the key from input image files, so you don’t need to manually set key for it.

Source

pub fn key(&self) -> Option<&str>

Returns the decrypter’s key, or None if it’s not set.

Source

pub fn set_key_from_str(&mut self, key: &str) -> Result<(), Error>

Sets the decrypter’s key to provided &str. If key’s length is not 32 bytes, the function fails and returns [Error].

Source

pub fn set_key_from_image(&mut self, file_content: &[u8])

Sets the key of decrypter from encrypted file_content image data.

§Arguments
  • file_content - The data of RPG Maker file
Source

pub fn decrypt(&mut self, file_content: &[u8]) -> Vec<u8>

Decrypts RPG Maker file content. Auto-determines the key from the input file.

§Arguments
  • file_content - The data of RPG Maker file.
§Returns
  • Vec<u8> containing decrypted data.
Source

pub fn encrypt(&self, file_content: &[u8]) -> Result<Vec<u8>, Error>

Encrypts file content.

This function requires decrypter to have a key, which you can fetch from System.json file or by calling set_key_from_image() with the data from encrypted image file.

§Arguments
  • file_content - The data of .png, .ogg or .m4a file.
§Returns
  • Vec<u8> containing encrypted data, or KeyError if key is not set.

Trait Implementations§

Source§

impl Default for Decrypter

Source§

fn default() -> Decrypter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.