Sample code for 30+ languages & platforms
Rust

Compute Glacier SHA256 Linear Hash of a File

See more Amazon Glacier Examples

Computes the Amazon Glacier SHA256 linear hash for a file.

Chilkat Rust Downloads

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

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

// The "linear hash" is simply the SHA256 hash of the file bytes.
crypt.set_hash_algorithm("sha256");

// Return the hash in lowercase hexidecimal format.
crypt.set_encoding_mode("hexlower");

let linear_hash_hex = crypt.hash_file_enc("qa_data/jpg/penguins.jpg").unwrap_or_default();
println!("SHA256 linear hash = {}", linear_hash_hex);