Rust
Rust
Example: Crypt2.EncryptEncoded method
Demonstrates how to call the EncryptEncoded method.Chilkat Rust Downloads
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");
// Encrypt the bytes 0x00, 0x01, 0x02, ... 0x0A
// and return the encrypted bytes using the lowercase hex encoding.
crypt.set_encoding_mode("hex_lower");
let encrypted = crypt.encrypt_encoded("000102030405060708090a").unwrap_or_default();
println!("{}", encrypted);
// Output:
// 9da2ae71a5378487114b430e5e230378
let decrypted = crypt.decrypt_encoded(&encrypted).unwrap_or_default();
println!("{}", decrypted);
// Output:
// 000102030405060708090a