Rust Requires Chilkat v11.0.0+
Rust
Unzip an AES Encrypted Text File directly into a String Variable
See more Zip Examples
A common need is to unzip from an AES encrypted Zip archive directly into a string variable, such that the unencrypted file never resides on disk, even temporarily. This example shows how to do it.Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let zip = chilkat::Zip::new();
// This example opens a WinZip-compatible AES encrypted
// .zip that contains a single file: hamlet.xml.
// It decrypts and unzips hamlet.xml directly into a string
// variable.
zip.set_password("secret");
if zip.open_zip("qa_data/hamlet.zip").is_err() {
println!("{}", zip.last_error_text());
return;
}
let entry = chilkat::ZipEntry::new();
if zip.entry_of("hamlet.xml", &entry).is_err() {
println!("{}", zip.last_error_text());
return;
}
// lineEndingBehavior:
// 0 = leave unchanged.
// 1 = convert all to bare LF's
// 2 = convert all to CRLF's
let line_ending_behavior = 0;
let src_charset = "utf-8".to_string();
let xml_text = entry.unzip_to_string(line_ending_behavior, &src_charset).unwrap_or_default();
println!("{}", xml_text);