weavatrix-rust 2.17.0

Protocol-independent Rust repository intelligence: typed evidence graphs for impact, architecture, APIs, Git, n8n, Dify, Agent catalogs, Mermaid, and Web3 ABI
Documentation
use sha3::{Digest, Sha3_256};
use std::fmt::Write as _;

pub(crate) fn sha3_256(bytes: &[u8]) -> String {
    encode(&Sha3_256::digest(bytes))
}

pub(crate) fn sha3_256_parts(parts: &[&[u8]]) -> String {
    let mut hasher = Sha3_256::new();
    for part in parts {
        hasher.update(part);
        hasher.update([0]);
    }
    encode(&hasher.finalize())
}

fn encode(hash: &[u8]) -> String {
    let mut out = String::from("sha3-256:");
    for byte in hash {
        let _ = write!(out, "{byte:02x}");
    }
    out
}