SHA-256 is the recommended stronger alternative to SHA-1. See FIPS PUB 180-4 for implementation details.

Either by using a dedicated library or implementing the algorithm in your language, show that the SHA-256 digest of the string "Rosetta code" is: 764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf

use sha2::{Digest, Sha256};
 
fn hex_string(input: &[u8]) -> String {
    input.as_ref().iter().map(|b| format!("{:x}", b)).collect()
}
 
fn main() {
    // create a Sha256 object
    let mut hasher = Sha256::new();
 
    // write input message
    hasher.update(b"Rosetta code");
 
    // read hash digest and consume hasher
    let result = hasher.finalize();
 
    let hex = hex_string(&result);
 
    assert_eq!(
        hex,
        "764faf5c61ac315f1497f9dfa542713965b785e5cc2f707d6468d7d1124cdfcf"
    );
 
    println!("{}", hex);
}
 