Sample code for 30+ languages & platforms
Rust

Obfuscate String

Demonstrates how to obfuscate and unobfuscate a string.

Chilkat Rust Downloads

Rust

let sb = chilkat::StringBuilder::new();

let s = "Hello World!".to_string();

let _ = sb.append(&s);
println!("{}", sb.get_as_string().unwrap_or_default());

// Output is "Hello World!";

// Obfuscate the string.
// This is NOT encryption.  It's just a simple obfuscation.
sb.obfuscate();
println!("{}", sb.get_as_string().unwrap_or_default());

// Output is 2GsgGhbSQVyG8Vb9

// -------------------------
// Unobfuscate.
let sb2 = chilkat::StringBuilder::new();
let s2 = "2GsgGhbSQVyG8Vb9".to_string();
let _ = sb2.append(&s2);
sb2.unobfuscate();

println!("{}", sb2.get_as_string().unwrap_or_default());

// Output is "Hello World!";