(path: &Path)
| 3771 | } |
| 3772 | |
| 3773 | fn compute_file_sha256_hex(path: &Path) -> Result<String, String> { |
| 3774 | let mut file = fs::File::open(path).map_err(|err| format!("open {}: {err}", path.display()))?; |
| 3775 | let mut hasher = Sha256::new(); |
| 3776 | let mut buffer = vec![0_u8; 64 * 1024].into_boxed_slice(); |
| 3777 | loop { |
| 3778 | let read = file |
| 3779 | .read(&mut buffer) |
| 3780 | .map_err(|err| format!("read {}: {err}", path.display()))?; |
| 3781 | if read == 0 { |
| 3782 | break; |
| 3783 | } |
| 3784 | hasher.update(&buffer[..read]); |
| 3785 | } |
| 3786 | Ok(format!("{:x}", hasher.finalize())) |
| 3787 | } |
| 3788 | |
| 3789 | fn compute_bytes_sha256_hex(bytes: &[u8]) -> String { |
| 3790 | let mut hasher = Sha256::new(); |
no test coverage detected