blob: b8c61da390f738c8ae7eab3d3ab41921c6c8c479 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use std::{path::Path};
use sha2::{Sha256};
use std::fs::File;
use hex_literal::hex;
use digest_io::HashReader;
use std::io::BufReader;
pub struct GameIso {
filepath: bool
}
impl GameIso {
pub fn new<P: AsRef<Path>>(path: P) -> () {
let file = File::open(path).unwrap();
let reader = BufReader::new(file);
let mut hasher: HashReader<Sha256, BufReader<File>> = HashReader::<Sha256, BufReader<File>>::new(reader);
hasher.hash_to_end();
let hash = hasher.finalize();
let s: String = hash.iter().map(|b| format!("{:02x}", b)).collect();
assert!(hash == hex!("a08ad2654831ab298071bdcdf727945efcfdd50d2b0e3512a3d361ee7b18296d"));
}
}
|