sqc 0.4.13

Software Code Quality - CERT C compliance checker
1
2
3
4
5
6
7
8
9
10
11
use anyhow::Result;
use sha2::{Digest, Sha256};
use std::fs;

pub fn calculate_file_hash(file_path: &str) -> Result<String> {
    let content = fs::read(file_path)?;
    let mut hasher = Sha256::new();
    hasher.update(&content);
    let result = hasher.finalize();
    Ok(format!("{:x}", result)[..8].to_string()) // First 8 chars of hash
}