Sample code for 30+ languages & platforms
Rust

Example: Crypt2.HashStringENC method

Demonstrates how to call the HashStringENC method.

Chilkat Rust Downloads

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

let s = "får".to_string();

// The string "får" in utf-8 is composed of these bytes: 0x66 0xC3 0xA5 0x72
crypt.set_charset("utf-8");

crypt.set_encoding_mode("hex_lower");
crypt.set_hash_algorithm("sha256");

// Get the hex string for the sha-256 hash of the utf-8 byte representation of the string
let hash_str = crypt.hash_string_enc(&s).unwrap_or_default();

println!("{}", hash_str);

// Output:
// cb8f773dd592337ed7f928012a60f48e1efb357beeda124a54461410e216fece