hashglass 0.1.0

Fast pentester-focused hash identifier — mode + cost + ready hashcat command. Handles secretsdump / containers / mixed dumps. Identification only.
Documentation
//! M5 maintainer tool: parse hashcat's `docs/hashcat-example-hashes.md` table
//! into `mode<TAB>example` rows on stdout.
//!
//! Deliberately network-free — you fetch the markdown out of band (a hash-ID
//! tool has no business carrying an HTTP stack), then:
//!   cargo run --bin sync -- hashcat-example-hashes.md > fixtures/hashcat_examples.tsv
//!
//! It cannot invent regexes from a single example (that stays hand-curated in
//! src/rules.rs); its job is the fixture/catalog side — refreshing the drift
//! fixtures and surfacing modes hashcat has that hashglass does not yet cover.

use std::fs;
use std::process::ExitCode;

fn main() -> ExitCode {
    let Some(path) = std::env::args().nth(1) else {
        eprintln!("usage: sync <path-to-hashcat-example-hashes.md>");
        eprintln!("  emits `mode<TAB>example` rows parsed from hashcat's example-hash table.");
        return ExitCode::from(2);
    };

    let text = match fs::read_to_string(&path) {
        Ok(t) => t,
        Err(e) => {
            eprintln!("error: cannot read {path}: {e}");
            return ExitCode::from(2);
        }
    };

    let mut count = 0usize;
    for line in text.lines() {
        let line = line.trim();
        if !line.starts_with('|') {
            continue;
        }
        // | mode | name | example |  →  ["mode", "name", "example"]
        let cells: Vec<&str> = line.trim_matches('|').split('|').map(str::trim).collect();
        if cells.len() < 3 {
            continue;
        }
        // Non-numeric first cell = header row or `---` separator → skip.
        let Ok(mode) = cells[0].parse::<u32>() else {
            continue;
        };
        let example = cells[2].trim_matches('`').trim();
        if example.is_empty() {
            continue;
        }
        println!("{mode}\t{example}");
        count += 1;
    }

    eprintln!("parsed {count} example(s) from {path}");
    ExitCode::SUCCESS
}