decrypt_archive

Function decrypt_archive 

Source
pub fn decrypt_archive(
    archive_data: &[u8],
) -> Result<Vec<ArchiveEntry>, ExtractError>
Expand description

A convenience function to decrypt an archive in a single call.

This is a wrapper around Decrypter::decrypt with automatic initialization.

§Parameters

  • archive_data: The content of the archive file.

§Returns

§Errors

§Example

use rpgmad_lib::decrypt_archive;
use std::{path::PathBuf, fs::{read, write, create_dir_all}};

let data = read("C:/Game/Game.rgss3a").unwrap();
let decrypted_entries = decrypt_archive(&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();
}