refactor(werkbank): extract soft-PLC provisioning + ICS probe into werkbank-exec (WB-04a) (#208)
CI / Check (push) Has been skipped
CI / Detect Changes (push) Successful in 3s
CI / Deploy Agent (push) Successful in 3m46s
CI / Deploy Dashboard (push) Successful in 2m53s
CI / Deploy Docs (push) Has been skipped
CI / Deploy MCP (push) Successful in 2m2s
CI / Check (push) Has been skipped
CI / Detect Changes (push) Successful in 3s
CI / Deploy Agent (push) Successful in 3m46s
CI / Deploy Dashboard (push) Successful in 2m53s
CI / Deploy Docs (push) Has been skipped
CI / Deploy MCP (push) Successful in 2m2s
This commit was merged in pull request #208.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
//! Finding fingerprint helper (a SHA-256 over the salient parts), shared by the
|
||||
//! probe modules for stable dedup keys. Mirrors the agent's `dedup` helper.
|
||||
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
/// A stable fingerprint over the given parts (order-sensitive, separated so
|
||||
/// `["ab","c"]` and `["a","bc"]` differ).
|
||||
pub fn compute_fingerprint(parts: &[&str]) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
for part in parts {
|
||||
hasher.update(part.as_bytes());
|
||||
hasher.update(b"|");
|
||||
}
|
||||
hex::encode(hasher.finalize())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn deterministic_and_hex() {
|
||||
let a = compute_fingerprint(&["repo", "rule", "1"]);
|
||||
assert_eq!(a, compute_fingerprint(&["repo", "rule", "1"]));
|
||||
assert_eq!(a.len(), 64);
|
||||
assert!(a.chars().all(|c| c.is_ascii_hexdigit()));
|
||||
assert_ne!(
|
||||
compute_fingerprint(&["ab", "c"]),
|
||||
compute_fingerprint(&["a", "bc"])
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user