use std::{env, fs::File, io::Read};

use sha3::sha3::Sha3_256;

fn main() {
    let args: Vec<String> = env::args().collect();

    if args.len() != 2 {
        eprintln!("Usage: {} <filename>", args[0]);
        std::process::exit(1);
    }

    let filename = &args[1];
    let mut file = File::open(filename).unwrap();

    let mut file_data = Vec::new();

    file.read_to_end(&mut file_data).unwrap();

    let mut sha = Sha3_256::default();

    sha.absorb(&file_data);
    let res: [u8; 32] = sha.squeeze();

    print!("SHA3-256: ");
    for x in res {
        print!("{:x}", x);
    }
    println!();
}
