MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / compute_file_sha256_hex

Function compute_file_sha256_hex

crates/openshell-driver-vm/src/driver.rs:3773–3787  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

3771}
3772
3773fn 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
3789fn compute_bytes_sha256_hex(bytes: &[u8]) -> String {
3790 let mut hasher = Sha256::new();

Callers 1

verify_descriptor_digestFunction · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected