README: Gitea badges, a "Where things live" note, downloads from releases.poli0981.dev, how 1.3.0 and older move over (one manual download), macOS no longer built, SHA256SUMS instead of GitHub attestations, and the donation links that only FUNDING.yml had. CONTRIBUTING: issues and merge requests on the GitLab mirror, patches by e-mail, CI on Gitea; Renovate, not Dependabot. SECURITY: reports by e-mail to security@poli0981.dev, never as a public issue; how releases are built and checked now. The privacy policy, EULA, terms and disclaimer name the update feed on releases.poli0981.dev (Cloudflare) instead of GitHub. ACCESSIBILITY (reviewed for 1.3.1), ARCHITECTURE, RELEASING (rewritten for the R2 release), CODE_OF_CONDUCT, ACKNOWLEDGEMENTS and CLAUDE.md follow; CLAUDE.md gains a "Forge & CI" section pointing at the ops runbook. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8.2 KiB
Architecture
HashTool is a .NET 10 solution with three shipped programs sharing one core library.
src/HashTool.Core hashing, checksum files, folder walking, settings (no UI; trim/AOT compatible)
src/HashTool.App Avalonia 12 desktop app (CheckHash.exe) — views, view models, services
src/HashTool.Cli `hashtool` command-line tool (System.CommandLine, NativeAOT)
tests/ Core.Tests, Cli.Tests, App.Tests (Avalonia headless); Compat/LegacyClient (1.1.x feed reader)
bench/ BenchmarkDotNet benchmarks (run by hand)
eng/ scripts used by CI and releases (translations, coverage, release notes, package checks)
build/ packaging inputs (Linux icon; macOS Info.plist, kept for 1.x identity)
Shared build settings: Directory.Build.props (version, nullable, analyzers, NuGet audit), Directory.Packages.props
(central package versions with transitive pinning), global.json (SDK and the Microsoft.Testing.Platform runner),
.config/dotnet-tools.json (vpk, nuget-license, CycloneDX; Renovate keeps them up to date with the packages,
renovate.json).
HashTool.Core
| Area | Types | Notes |
|---|---|---|
| Hashing | HashEngine, HashType, HashAlgorithms, HashResult, HashMatcher, TextHashing |
One read per file for any number of algorithms: double-buffered reads (1 MiB, 4 MiB above 1 GiB), each block fed to every algorithm in parallel; BLAKE3 uses its multi-threaded update for large blocks. CRC32 is big-endian (as 7-Zip/SFV); HashMatcher still accepts the reversed order Hash Tool 1.1 wrote. TextHashing turns text into the bytes the Hash Text page and hashtool hash - hash: UTF-8/UTF-16 without a byte order mark, LF or CRLF line breaks, nothing appended. |
| Checksum files | ChecksumParser, ChecksumWriter, ChecksumDocument, ChecksumFileNames |
Reads GNU (hash name, *name, escaped names), BSD tagged, SFV, xxhsum XXH3_ and bare sidecar hashes; writes GNU/BSD/SFV/JSON/CSV. The algorithm comes from the line, then the file name, then the user's choice, then the hash length. Paths may not point to UNC or device locations; CSV output neutralises formulas. |
| Files | FileEnumerator, FileErrors |
Walks folders without following symbolic links or junctions, skips unreadable folders, optionally hidden files. |
| Processing | BatchProcessor, HashJob, IHashJobObserver<T> |
Small files in parallel (default min(cores, 4)), files ≥ 1 GiB in a separate lane, one at a time in HDD mode; per-file time-out; every item is reported exactly once. |
| Configuration | AppSettings, SettingsStore |
config.json with a schema version; atomic writes (temp file + move), values clamped on load, a corrupt file is backed up as config.json.bak-<time>, 1.x font settings are migrated. |
HashTool.App
- Composition —
AppHostbuilds aMicrosoft.Extensions.DependencyInjectioncontainer (services and view models are singletons).Program.Mainruns Velopack hooks first, then--smoke-test, single-instance forwarding and Avalonia. - Views and view models — compiled bindings everywhere;
App.axamlmaps each view model to its view.FileListViewModelBaseholds what Generate and Verify share: importing (background enumeration, batches of 1000), filtering, running aBatchProcessorwith UI updates pumped every 100 ms, and the summary dialog.TextHashViewModel(Hash Text) hashes text in memory with every algorithm, shortly after each change. - Localization —
LocalizationServicereads the satellite resources, detects the system language, sets the culture (includingDefaultThreadCurrentCulture, so async work keeps it) and right-to-left flow. Views bindLocalization[Key]; view models swap theirLocalizationProxywhen the language changes, which refreshes every binding. Status texts are stored as enums and translated by converters, so they follow language changes. - Services — dialogs, file pickers, clipboard and launcher behind interfaces (
UiServices.cs);SettingsServicedebounces saves;ThemeService/ThemePalettesswap brush resources;FontServicepicks per-script fonts;UpdateServicewraps Velopack (HTTP sourcehttps://releases.poli0981.dev/hashtool, stable channel). - Infrastructure — logging to daily files and an in-memory sink for the Developer console (
Logging/), crash reports,AppPaths(HASHTOOL_DATA_DIRoverride), command-line parsing, single instance (named mutex/lock file plus a per-user named pipe), Windows shell integration underHKCU\Software\Classes, on-demand elevation, and the headless smoke test.
HashTool.Cli
hashtool hash | verify | check | algorithms, built on Core; hash - reads standard input. Exit codes follow sha256sum: 0 success, 1 failed or
mismatched file, 2 usage error or unreadable checksum file. Published per platform as a single NativeAOT executable.
Tests
HashTool.Core.Tests— known-answer vectors for every algorithm, engine, parser/writer, enumerator, batch processor, settings store. CI requires at least 80% line coverage of Core.HashTool.Cli.Tests— commands, output formats and exit codes.HashTool.App.Tests— Avalonia headless: every page in several languages, a create-and-verify flow, translation integrity (keys, placeholders, Languages.json ↔ resx ↔ project, satellite assemblies, unused keys), language detection, and accessibility (AccessibilityTests: a real, translated automation name for every control, headings, Tab inside file rows, focus when buttons swap, WCAG contrast of every theme palette; see ACCESSIBILITY.md).tests/Compat/LegacyClient— not in the solution: reads a release folder (or a GitHub feed) with Velopack 0.0.1298, the library inside Hash Tool 1.1.x. The release upgrade gate used it until 1.3.0; it stays for a possible bridge release (see RELEASING.md).
CI and analysis
Everything runs on Gitea Actions (.gitea/workflows; the runner is the maintainer's PC, Windows jobs in host mode,
Linux jobs in Docker). ci.yml builds and tests on Windows and Linux, security.yml checks packages, licences and
workflows and calls the shared scan of the ops repository poli0981/.github (gitleaks, Opengrep, osv-scanner,
NuGetAudit), qodana.yml runs Qodana for .NET (settings in qodana.yaml), and release.yml builds and publishes
releases (RELEASING.md). The ops repository's runbook, docs/GITEA-MIGRATION.md, describes the forge,
the runner and the schedules (13:00–16:00 UTC only).
Adding a hash algorithm
In maintenance mode an algorithm is added only on real demand (CONTRIBUTING.md, "Hash algorithms"). What it touches:
HashType: append only, never rename. Settings store the name ("SHA256"), an unknown name resetsconfig.json(so would a downgrade after a new algorithm was chosen), and the name is what the UI, the CLI and-ashow.HashAlgorithms:GuessPriority(every algorithm must be listed),Aliases,SizeInBytes,FileExtension,BsdTag,IsInsecure.HashFunction.Create: the implementation.HashEnginecreates every requested function before reading, so one that can fail on some platforms (the SHA-3 of .NET on macOS and Windows 10) breaks unrelated rows: use a managed implementation.ChecksumFileNames: extensions and well-known file names (B2SUMS…). The Windows context menu uses the same list, andbuild/macos/Info.plistmust match it (PackagingTests).- Digests of the same length become guesses (64 hex digits: SHA-256, BLAKE3…): Verify hashes every candidate in one read, except when the Default algorithm of the page has that length.
- Tests:
KnownAnswerTests(published vectors),EdgeCaseTestsandCliTests(both assert thatsha3is unknown today),HashMatcherTests; docs: README, USAGE,hashtool hash --help.
Benchmarks
dotnet run -c Release --project bench/HashTool.Benchmarks -- --filter '*'
LargeFileBenchmarks compares the engine with SHA256.HashData(FileStream); SmallFilesBenchmarks compares sequential
hashing with BatchProcessor. On an i7-14700KF with a warm cache: SHA-256 of 256 MiB 129 ms vs 221 ms, BLAKE3 57 ms,
XXH3 36 ms, CRC32 34 ms; 2,000 × 16 KiB files 26 ms in parallel vs 89 ms sequentially.