Starting with all the printable characters, I want to get the sha256 characters one by one and compare them to the sha256 taken from the input.
My code is :
use hex_literal::hex;
use sha2::{Digest, Sha256};
use std::io;
fn main() {
let printable = vec![b" ", b"!", b"#"];
enter code here
let mut hash_target = String::new();
io::stdin()
.read_line(&mut hash_target)
.expect("Something Wrong!").to_owned();
let hash_target = &hash_target[..];
for i in 0..printable.len() {
let mut sha256 = Sha256::new();
sha256.update(printable[i]);
let result = sha256.finalize();
if result[..]
== hex!(hash_target)[..]
{
println!("True");
}
}
}
I do not know how to give the value of the sha read from the input to the hex function.