pub struct Decrypter { /* private fields */ }
Implementations§
Source§impl Decrypter
impl Decrypter
Sourcepub fn new() -> Self
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.
Sourcepub fn set_key_from_str(&mut self, key: &str) -> Result<(), Error>
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
].
Sourcepub fn set_key_from_image(&mut self, file_content: &[u8])
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
Sourcepub fn encrypt(&self, file_content: &[u8]) -> Result<Vec<u8>, Error>
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, orKeyError
if key is not set.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Decrypter
impl RefUnwindSafe for Decrypter
impl Send for Decrypter
impl Sync for Decrypter
impl Unpin for Decrypter
impl UnwindSafe for Decrypter
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