Sample code for 30+ languages & platforms
Rust

UU Encoding and Decoding

See more Encryption Examples

Demonstrates how to UU encode and decode.

Chilkat Rust Downloads

Rust
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let crypt = chilkat::Crypt2::new();

let s1 = "This string is to be UU encoded".to_string();

crypt.set_uu_mode("666");
crypt.set_uu_filename("something.txt");

// UU encode:
let s2 = crypt.encode_string(&s1, "ansi", "uu").unwrap_or_default();

// Note: Call crypt.Encode instead of crypt.EncodeString
// to UU encode binary bytes (i.e. non-text binary data).

println!("{}", s2);

// UU decode:
let crypt2 = chilkat::Crypt2::new();
let s3 = crypt2.decode_string(&s2, "ansi", "uu").unwrap_or_default();

// Note: Likewise, call crypt.Decode to decode non-text binary data.

println!("{}", s3);

// Show the file permissions mode and filename found
// in the UU encoded data:
println!("UuMode = {}", crypt2.uu_mode());
println!("UuFilename = {}", crypt2.uu_filename());