CI / Format and clippy (push) Successful in 1m57s
CI / Dependency audit (push) Successful in 13s
CI / Check desktop app (Linux) (push) Successful in 3m54s
CI / Tests (Linux) (push) Failing after 7m25s
Release / Create release (push) Successful in 6s
Release / CLI (linux-aarch64) (push) Successful in 1m48s
Release / CLI (linux-x86_64) (push) Successful in 2m39s
Release / Desktop app (linux-aarch64) (push) Successful in 10m9s
Release / Desktop app (linux-x86_64) (push) Successful in 12m20s
Release / Desktop app (windows) (push) Successful in 7m32s
Release / Build latest.json (push) Successful in 5s
Completes the English-only standardization for code, comments, scripts and CI templates (UI/CLI-facing strings stay bilingual pt-BR/en, untouched). Covers the remaining crates/, apps/gui/ui/ and apps/gui/src-tauri/ comments, .gitea/ workflow and template comments, .githooks/ hooks, and the scripts/ source comments for the files already renamed in a prior commit (check.sh, generate-logo.py, install-hooks.sh). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VAyr8d7HuAdUGB6aA5xmDD
46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
//! Forensic integrity hashes: computes MD5, SHA-1, and SHA-256 in a single pass.
|
|
|
|
use md5::Md5;
|
|
use serde::{Deserialize, Serialize};
|
|
use sha1::Sha1;
|
|
use sha2::{Digest, Sha256};
|
|
|
|
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub struct Hashes {
|
|
pub md5: String,
|
|
pub sha1: String,
|
|
pub sha256: String,
|
|
}
|
|
|
|
#[derive(Default)]
|
|
pub struct MultiHasher {
|
|
md5: Md5,
|
|
sha1: Sha1,
|
|
sha256: Sha256,
|
|
}
|
|
|
|
impl MultiHasher {
|
|
pub fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
pub fn update(&mut self, data: &[u8]) {
|
|
self.md5.update(data);
|
|
self.sha1.update(data);
|
|
self.sha256.update(data);
|
|
}
|
|
pub fn finalize(self) -> Hashes {
|
|
let hex = |b: &[u8]| b.iter().map(|x| format!("{x:02x}")).collect::<String>();
|
|
Hashes {
|
|
md5: hex(&self.md5.finalize()),
|
|
sha1: hex(&self.sha1.finalize()),
|
|
sha256: hex(&self.sha256.finalize()),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn hash_bytes(data: &[u8]) -> Hashes {
|
|
let mut h = MultiHasher::new();
|
|
h.update(data);
|
|
h.finalize()
|
|
}
|