Rust
Rust
Example: Crypt2.DecryptStringENC method
Demonstrates how to call the DecryptStringENC method.Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let crypt = chilkat::Crypt2::new();
crypt.set_crypt_algorithm("aes");
crypt.set_cipher_mode("cbc");
crypt.set_key_length(128);
crypt.set_encoded_key("000102030405060708090A0B0C0D0E0F", "hex");
crypt.set_encoded_iv("000102030405060708090A0B0C0D0E0F", "hex");
crypt.set_encoding_mode("base64");
// Return the base64 encoded encrypted bytes
let encoded_encrypted = crypt.encrypt_string_enc("Hello World!").unwrap_or_default();
println!("Encrypted: {}", encoded_encrypted);
// Output:
// Encrypted: qiq+IFhcjTkEIkZyf31V/g==
// Decrypt
let original_text = crypt.decrypt_string_enc(&encoded_encrypted).unwrap_or_default();
println!("Decrypted: {}", original_text);
// Output:
// Decrypted: Hello World!