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

18 lines
478 B
Rust

use std::io::Read;
use algorithms::crc::Crc;
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 crc = if use_ffi {
algorithms::crc::ffi::Crc32::checksum(&input)
} else {
algorithms::crc::Crc32::checksum(&input)
};
println!("{crc:08x}");
}