Rust Requires Chilkat v11.0.0+
Rust
Unzip Encrypted Text into a String Variable
See more Zip Examples
Demonstrates how to open an encrypted .zip archive and unzip a text file directly into a string variable.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();
// Set the password required for decrypting.
zip.set_decrypt_password("myPassword");
if zip.open_zip("encrypted.zip").is_err() {
println!("{}", zip.last_error_text());
return;
}
// Locate the file within the Zip to be unzipped into a string variable:
let entry = chilkat::ZipEntry::new();
if zip.entry_matching("*.csv", &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 str_csv = entry.unzip_to_string(line_ending_behavior, &src_charset).unwrap_or_default();
println!("{}", str_csv);