nucleo-l053r8-benches/crates/algorithms/src/bin/sha256sum.rs
2025-07-22 14:10:34 +02:00

18 lines
591 B
Rust

use std::io::Read;
use algorithms::hash::format_digest;
fn main() {
let args: Vec<String> = std::env::args().collect();
let use_ffi = args.contains(&"-c".to_string());
let mut input = Vec::new();
std::io::stdin()
.read_to_end(&mut input)
.expect("could not read from stdin");
let hash = if use_ffi {
algorithms::hash::ffi::sha2_256_oneshot(&input).expect("could not hash your input data")
} else {
algorithms::hash::sha2_256_oneshot(&input).expect("could not hash your input data")
};
println!("{}", format_digest(&hash));
}