FileForums

FileForums (https://fileforums.com/index.php)
-   Conversion Tutorials (https://fileforums.com/forumdisplay.php?f=55)
-   -   Game files integrity check - XHash Library (https://fileforums.com/showthread.php?t=103790)

BLACKFIRE69 03-09-2020 05:52

Game files integrity check - XHash Library
 
6 Attachment(s)
XHashEx v2.0
File Hashing & Checksum Verification API for Inno Setup
84 algorithms · multi-threaded · Win32 DLL (32 & 64-bit Windows) · by BLACKFIRE69

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━

▌ OVERVIEW
XHashEx is a lightweight, high-performance hashing library crafted for Inno Setup. It generates and verifies checksum files for entire folders, hashes single files, and exposes 84 hashing algorithms — from fast CRC32/XXHash to the full cryptographic suite (SHA-2, SHA-3, BLAKE2/3 …) — all from a single DLL with live per-file and overall progress tracking. Ideal for verifying the integrity of downloaded payloads, large data sets, or already-installed files before continuing an installation.

▌ TECHNICAL SPECIFICATIONS
  • Version — v2.0
  • Author — BLACKFIRE69
  • Build — 2026-Jun
  • Compatibility — Inno Setup v6.0 or later (Required)
  • Platform — Win32 DLL (runs on 32-bit and 64-bit Windows)

▌ WHAT'S NEW (v2.0)

⚠ BREAKING CHANGE — No Backward Compatibility
Every exported function was renamed with an XH_ prefix and a cleaner name (e.g. CalculateHashesForDirXH_GenerateDir). v1.x scripts will not work until imports are updated — swap to the bundled XHashEx.iss header. The ProcessMessages export was removed entirely; the DLL pumps the message queue itself.

✦ Multi-Threading Support (NEW)
Hash many files in parallel via a worker-thread pool, count selectable at runtime with XH_SetThreadCount (XH_THREADS_SINGLE / N / XH_THREADS_AUTO). OFF by default — opt in with one call.

✦ Light Callback Mode (NEW)
On folders with tens of thousands of files, per-file callback crossings into Pascal Script dominate the runtime, not the hashing. XH_SetCallbackMode(XH_CALLBACK_LIGHT) keeps directory runs fast in BOTH thread modes: failures/missing/final file are always reported, plus a ~10×/s sampled tick — the log still records every file. OFF by default.

✦ Measured Performance (28,036 files · xxHash32 · SATA SSD · Windows 11)
Code:

╭───────────────────┬──────────────────────┬──────────────┬───────────╮
│ Mode              │ Duration v1.4+ (Mar) │ Duration 2.0 │ Speedup  │
├───────────────────┼──────────────────────┼──────────────┼───────────┤
│ ST generation    │        7 min 32 sec │      32 sec~14×      │
│ ST verification  │        8 min 40 sec │      35 sec~15×      │
│ MT generation    │        5 min 36 sec │      26 sec~13×      │
│ MT verification  │        6 min 13 sec │      28 sec~13×      │
╰───────────────────┴──────────────────────┴──────────────┴───────────╯

At that rate the SATA SSD itself is the limit (~420–500 MB/s); NVMe raises the ceiling further.

✦ Byte-Weighted Progress (NEW)
Overall progress reflects the share of BYTES hashed, so the bar moves smoothly even when file sizes vary wildly. Toggle with XH_SetProgressMode (on by default).

✦ Accurate MT Progress + Instant Pause
In MT runs the overall percent tracks exactly what's reported to your callback — it reaches 100% precisely when the run finishes — and Pause/Resume/Cancel take effect immediately even under heavy load.

✦ Significant Performance Improvements
Throughput scales with cores (auto-capped to keep disk access sane), no extra per-file metadata pass before hashing, each worker reuses its hash object across files, and the DLL pumps the message queue itself.

✦ New High-Performance File Search Engine
The old file-search code is replaced with a faster wide-API scanner customized for hashing (lean path-only mode), pre-compiled wildcard masks, and full case-insensitive $"regex" support.

✦ Expanded Algorithm Set
The full cryptographic suite is now exposed — 80+ algorithms total (added SHA-224/384, SHA-3/Keccak, RIPEMD-160/320, WhirlPool, BLAKE2B/2SP/2BP, GOST, Snefru, Tiger/Haval variants …).

✦ Unicode Fixes
Checksum and log files are written/read as UTF-8, so non-Latin file names (Cyrillic, CJK …) round-trip correctly instead of being mangled.

✦ Performance Upgrade
Read buffer and hash object reused across files (no per-file alloc), files opened once with sequential-scan I/O, and progress callbacks throttled to whole-percent changes.

✦ Bug Fixes & Stability
Fixed a UI-freeze regression during long operations, corrected progress reporting on the verification path, and various smaller fixes.

✦ Refreshed Example & Docs
A new, comprehensive Inno Setup 6 demo (XHashEx_Example.iss) with a Multi-threaded toggle (paired with light callback mode), a live Elapsed / Speed / ETA readout, and a final Duration + average-throughput summary — plus an updated quick-reference.

▌ KEY FEATURES

✦ Directory Checksum Generation
Recursively hash an entire folder into a single checksum file (.md5/.sha1/.sha256/.sfv …), one algorithm per run.

✦ Checksum Verification
Verify files against a checksum file with an explicit algorithm, or in auto-detect mode (CRC32/MD5/SHA1/SHA256/SHA512) for mixed-algorithm lists.

✦ Single-File Hashing
Compute and return the digest of one file, or verify it against a known hash.

✦ Powerful File Selection (Masks)
Include/Exclude using wildcards, sub-folders, @list files, and case-insensitive $"regex" patterns — mix freely with '|'.

✦ Multi-Threaded Hashing
Optionally hash in parallel across a worker-thread pool (selectable count, or auto). Result callbacks stay on your calling thread — safe to enable with no other code changes.

✦ Live Progress Tracking
Per-file %, overall % (byte-weighted by default), file size, bytes processed, total file count, per-file status (Ok / Bad / Missing).

✦ Process Control
Pause, Resume, and Stop a running operation safely at any point.

✦ Customizable Logging
Optional log file with fully customizable log message strings.

✦ Checksum File Comments
Write custom comment lines into the header of the generated checksum file.

✦ Attribute Control
Optionally include hidden and/or system files when scanning.

✦ Performance Tuning
Adjustable read buffer (default 4 MB) for max throughput on very large files; hash object + buffer reused across files.

✦ Full Unicode Support
Non-Latin file names handled correctly; checksum and log files written as UTF-8.

✦ Previous-Hash Cache
Append new results to existing in-memory hashes to build cumulative checksum files across multiple passes.

✦ Bonus: File Search / Enumeration API
A built-in wide-API file scanner (wfs_*) for listing files/directories by the same mask/regex syntax, with optional per-file size, attributes, and CRC32.

▌ SUPPORTED ALGORITHMS (80+ total)
Code:

╭───────────────────┬──────────────────────────────────────────────────────╮
│ Group            │ Algorithms                                          │
├───────────────────┼──────────────────────────────────────────────────────┤
Checksum          │ CRC32                                                │
MD                │ MD2, MD4, MD5                                        │
SHA-1 / SHA-2    │ SHA0, SHA1, SHA-224/256/384/512, SHA-512/224, /256  │
SHA-3 / Keccak    │ SHA3-224/256/384/512, Keccak-224/256/288/384/512    │
RIPEMD            │ RIPEMD, RIPEMD-128/160/256/320                      │
BLAKE            │ BLAKE2S, BLAKE2B, BLAKE2SP, BLAKE2BP, BLAKE3        │
Tiger            │ Tiger & Tiger2 (3/4/5 rounds x 128/160/192)          │
Haval            │ Haval (3/4/5 rounds x 128/160/192/224/256)          │
Other crypto      │ WhirlPool, GOST, GOST R 34.11-2012, HAS-160, Snefru, │
│                  │ Grindahl, Panama, RadioGatun                        │
Fast / non-crypto │ MurmurHash3, XXHash32                                │
╰───────────────────┴──────────────────────────────────────────────────────╯

Each algorithm has a numeric id (1..84), listed with XH_* constants in XHashEx.iss. Auto-detect verification supports only CRC32/MD5/SHA1/SHA256/SHA512; others need their explicit id.

▌ MASKS (Include / Exclude)
Matched against the file's RELATIVE path + name, combined with '|'. Blank or '*' means all files.
Code:

*.dll|*.exe                  wildcards / extensions
images\png\*                a sub-folder
G????info.*                  ? = single char
@"IncludeFiles.txt"          @list file (one mask per line)
$"^setup.*\.exe$"            case-insensitive regex
*.dll|@list.txt|$"\d{4}"    mix all three

▌ EXPORTED API FUNCTIONS
(v1.x names in parentheses)
  • Generation — XH_GenerateDir (CalculateHashesForDir), XH_GenerateDirEx, XH_HashFile (CalculateFileHash)
  • Verification — XH_VerifyDir (VerifyHashesFromFile), XH_VerifyDirEx, XH_VerifyDirAuto, XH_VerifyDirAutoEx, XH_VerifyFile
  • Process Control — XH_Pause, XH_Resume, XH_Stop, XH_GetStatus
  • Configuration — XH_SetThreadCount, XH_SetCallbackMode, XH_SetProgressMode, XH_SetMaxProgress, XH_SetBufferSize, XH_GetBufferSize, XH_SetIncludeAttribs, XH_SetLogFile, XH_SetLogMessage, XH_HideComments, XH_AddComment, XH_ClearComments
  • Results & Logging — XH_GetLog, XH_ClearLog, XH_GetHashText, XH_ClearHashText, XH_GetVerifiedFileCount
  • Utility — XH_ByteOrTb
  • File Search (wfs_*) — wfs_FindFiles / wfs_FindFilesEx / wfs_FindFilesExFast, wfs_FileCount, wfs_PickFile, wfs_PickFileList, wfs_DirCount, wfs_PickDir, wfs_SaveFileList, wfs_SaveDirList, wfs_FindFree

▌ QUICK START EXAMPLES

Example 1 — Generate a checksum file for a folder
Code:

#include "XHashEx.iss"

function MyProgress(FileName: WideString; FileSize: Extended;
  FileProgress, TotalProgress, TotalFiles, FileCounted, StatusCode: Integer): Boolean;
begin
  // update your UI here ... (no ProcessMessages needed)
  Result := False// return True to abort
end;

if XH_GenerateDir(
    ExpandConstant('{app}\checksums.sha256'),
    ExpandConstant('{app}'),
    XH_SHA256, @MyProgress) = XH_PROCESS_DONE then
  Log('Checksum file created.');

Example 2 — Verify a checksum file
Code:

case XH_VerifyDir(
      ExpandConstant('{app}\checksums.sha256'),
      ExpandConstant('{app}'),
      XH_SHA256, 0, True, @MyProgress) of
  XH_PROCESS_DONE:          Log('All files verified.');
  XH_INVALID_CHECKSUM_FILE: Log('Checksum file missing/invalid.');
  XH_PROCESS_ABORTED:      Log('Cancelled by user.');
end;

Example 3 — Verify a mixed-algorithm list (auto-detect)
Code:

// auto-detect handles CRC32/MD5/SHA1/SHA256/SHA512
XH_VerifyDirAuto(
  ExpandConstant('{app}\hash_mixed.md5'),
  ExpandConstant('{app}'),
  0, False, @MyProgress);  // PreviousFileCount, no log file

Example 4 — Hash a single file
Code:

Digest := XH_HashFile(
  ExpandConstant('{app}\game.exe'), XH_XXHASH_32, @MySingleProgress);
MsgBox('XXHash32: ' + Digest, mbInformation, MB_OK);

Example 5 — Generate with masks (wildcards + regex), hidden files included
Code:

XH_SetIncludeAttribs(True, False);  // include hidden, not system
XH_SetBufferSize(4096);              // 4 MB read buffer

XH_GenerateDirEx(
  ExpandConstant('{app}\data.md5'),
  ExpandConstant('{app}'),
  '*.dll|*.exe|$"^data\d+\.bin$"',    // include masks
  '*.log|$"\.(tmp|bak)$"',            // exclude masks
  True, False, XH_MD5, @MyProgress);

▌ DISTRIBUTION FILES
  • XHashEx.dll — the hashing library (single DLL)
  • XHashEx.iss — header for Inno Setup (constants, types, imports)
  • XHashEx_Example.iss — full working demo (generate / verify / single file, algorithm picker, masks, pause/resume, log)
  • _Usage.txt — quick reference for masks and algorithm ids

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━

Feedback, bug reports and suggestions are welcome. Enjoy!
— BLACKFIRE69


.

BLACKFIRE69 05-09-2020 11:58

XHash Update 1.1v
 
XHash Update 1.1v

  • Added more Algos.

    - md5
    - sha1
    - sha256
    - sha512

  • Fixed some bugs.

_

Balaji007 05-10-2020 10:15

I am appreciating your work friend. Your tools are pretty cool

Epic Titan 69 20-02-2021 21:37

Quote:

Originally Posted by BLACKFIRE69 (Post 487767)
XHash Update 1.1v

  • Added more Algos.

    - md5
    - sha1
    - sha256
    - sha512

  • Fixed some bugs.

_

Can You Add This Option (Game files integrity check - XHash Library)
To This Script

BLACKFIRE69 08-02-2022 11:24

XHash New Update
 
Update available!


What's New:
  • Stable.
  • Faster.
  • Supports both generate and verify checksums.


ChecksumX
Code:

USAGE:
 ChecksumX.exe [generate] [autoclose] [/x=<ExcludeFile>] <Checksum_File> <Algorithm_Index> <Base_Path>

OPTIONS:
 generate  - Generate a checksumfile.
 autoclose - Automatically close when the process is done.
 /x=<file> - Excluding file masks list for generate only.


_

Lord.Freddy 05-08-2022 04:29

Hello. Your file is good, but if I use the VclStyle skin, when the dll file wants to show the error box, the installation file closes suddenly. can you remove the error box from dll :D?

BLACKFIRE69 05-08-2022 06:32

Quote:

Originally Posted by Lord.Freddy (Post 497868)
Hello. Your file is good, but if I use the VclStyle skin, when the dll file wants to show the error box, the installation file closes suddenly. can you remove the error box from dll :D?

can you specify what the error message is?

Lord.Freddy 05-08-2022 07:32

Quote:

Originally Posted by BLACKFIRE69 (Post 497870)
can you specify what the error message is?

https://cdn.discordapp.com/attachmen...4/Rec_0001.mp4

See the error in this link:)

BLACKFIRE69 05-08-2022 07:47

Quote:

Originally Posted by Lord.Freddy (Post 497871)

sorry i didn't see any error with VclStyle. anyway i'll attach the non-messagebox version of XHash.
if this doesn't work either, send me your sample script so i can take a look.

.

Lord.Freddy 05-08-2022 11:10

Quote:

Originally Posted by BLACKFIRE69 (Post 497872)
sorry i didn't see any error with VclStyle. anyway i'll attach the non-messagebox version of XHash.
if this doesn't work either, send me your sample script so i can take a look.

.

here is my script, please fix the problem(Setup Crash when i chose Cancel button). thank:)

Cesar82 05-08-2022 21:20

1 Attachment(s)
Quote:

Originally Posted by Lord.Freddy (Post 497873)
here is my script, please fix the problem(Setup Crash when i chose Cancel button). thank:)

From what I could understand you can't use MesageBox inside the Callback.
Try with the script attached.

BLACKFIRE69 09-08-2022 06:20

XHash_Next v1.0
 
XHash_Next v1.0

Quote:

-- Added more algorithms.
-- Added log file for verification.
-- Added support for multiple algorithms in one hash file (ex: hash_mixed.md5) for verification. (Only for MD5, SHA1, SHA256, SHA512)
Code:

hash_mixed.md5

; Generator:  XHashNext DLL v1.0
; Algorithm:  MD5 (128 bits)
; No. Files:  14


; MD5
AC3856A351B3C13556B2386CD13BB6CA  cover.jpg
12F6B355C84327092D1115E5B1DB97D1  GameInfo.txt
ABD14375A3126F9296DCD88132E9652F  OverviewInfo.txt
18FAD69BBCE73113C4A6FB211E6A844F  PicForm.png

; SHA1
F81A451604B9C3606925A2AB3F406CC5C56C729E  PicForm0.png
4B65BA757C862625850D480D574200CEFCDFF162  Reqirements.txt
544A11C86AD0BCBF0ED01019E8250F64A30594EE  Ubuntu.ttf

; SHA256
26D21E5C309FAB938F378A83825284E231B056F0A1894078CF4750F015A7DFC3  wallpapers1.jpg
AE9EE7E81B55B54745B1B5A60F715A52DEDCE1527F154871F3BBDFEAEC9D52EB  wallpapers2.jpg
22022B461C6AF2EBFC3EF817EA941EE5BF7A53B163BFCD26F0CB2C66DC7EC7B0  wallpapers3.jpg
B9232B0D21C4EE1ADAB083C04505322C6F22A6C7008E3E81185ABBC06F6590F5  wallpapers4.jpg

; SHA512
40268B8DF3C4369930AC928B2793F29DF8007D237D3323A7E4F1EF7BBE1CD270035B2E8C01C4DE0E08492914CB6E2FB2146BBB878143172153D480B3FC80B1AD  wallpapers5.jpg
9A06694CB047301BC9DA1120139A70EFA9BCF7439C23705B590844B4D812504462CD023459BB5914BCD4542F512A5FDE0FF617568C016E149451D60FDE19CFF1  Wallpaper_color.jpg
A640305651EFE50B6F62BC0BBF9E53F8E23936B971E1C05289C0B38FF576C86DB3A305F6E02E42CA6E1C493664BE10C930BAA15433EBF3956A3C9D49670635A6  Wallpaper_color2.jpg


Quote:

Algorithm:

CRC32
MD5
SHA1
SHA256
SHA512
SHA512_256
SHA3_256
SHA3_512
BLAKE2_128
BLAKE2_256
BLAKE3_256
HAVAL3_128
HAVAL3_256
RIPEMD_128
RIPEMD_256
TIGER_128
TIGER_192
TIGER2_128
TIGER2_192
MURMURHASH_32
XXHASH_32


Functions:

{ Directory }
function CalculateHashesForDir(ChecksumFile, BasePath: WideString; HashAlgo: Integer; Callback: TMultiHashCallback): Integer;
function VerifyHashesFromFile(ChecksumFile, BasePath: WideString; HashAlgo: Integer; LogFile: Boolean; Callback: TMultiHashCallback): Integer;
function VerifyHashesAutoFromFile(ChecksumFile, BasePath: WideString; LogFile: Boolean; Callback: TMultiHashCallback): Integer;

{ Single file }
function CalculateFileHash(const FileName: WideString; const HashAlgo: Integer; Callback: TSingleFileHashCallback): WideString;
function VerifyFileHash(FileName, HashHexStr: WideString; HashAlgo: Integer; LogFile: Boolean; Callback: TSingleFileHashCallback): Integer;

{ Other }
function SetHashLogMessage(const MessageText: WideString; const MsgID: Integer): Boolean;
procedure SetHashLogFile(const FileName: WideString);
procedure StopHashProcess;
procedure PauseHashProcess;
procedure ResumeHashProcess;


thanks to @Cesar82 for the suggestions for the XHash_Next and testing it.

.

BLACKFIRE69 09-08-2022 13:00

XHash_Next - Update
 
XHash_Next - Update

Quote:

Also added CRC32 support for the "VerifyHashesAutoFromFile".

(currently "VerifyHashesAutoFromFile" supports crc32, md5, sha1, sha256 and sha512)
.

Grumpy 10-08-2022 09:30

Thanks for all these BLACKFIRE69, nice work, keep it up :)

BLACKFIRE69 17-08-2022 05:20

XHashNext - Update
 
XHashNext - Update

Quote:

-- Some improvements.
-- Fixed a minor bug in reading the checksum file.
-- Fixed percentage issues.
-- Fixed an issue where the process would still run after calling stop when "callback" was "nil".
https://i.ibb.co/SfKdTzM/003510.png

Thanks to @Cesar82

check the first post.

BLACKFIRE69 30-11-2022 05:42

XHashNext + ChecksumXNext - Updates
 
XHashNext + ChecksumXNext - Updates:

Code:

What's new

* Added some new error codes.
* Updated file search.
* Some improvements.


latest version added to first post.


,

BLACKFIRE69 22-12-2022 08:54

ChecksumXNext
 
Update available!

Code:

What's new:

- Minor improvements.


Carldric Clement 14-01-2023 08:08

4 Attachment(s)
Nothing happen to see the Memo and also the Label which is quite on progressing hash generated on Delphi FMX. But the result works fine. :)

Generate with the directory
Code:

function GenerateHashMultiCallback(FileName: WideString; FileSize: extended;
  FileProgress, TotalProgress, TotalFiles, FileCounted,
  StatusCode: Integer): Boolean;
begin
  Form5.Label9.Text := Format(XH_FILENAME, [ExtractFileName(FileName)]);
  Form5.Label10.Text := Format(XH_FILEPOSITION, [ByteOrTb((FileSize * FileProgress) / 100), ByteOrTb(FileSize)]);
  Form5.Label11.Text := Format(XH_PERCENTAGE, [FileProgress]);

  Form5.Label12.Text := Format(XH_PERCENTAGE, [TotalProgress]);
  Form5.ProgressBar1.Value := TotalProgress;

  case StatusCode of
    H_FILE_HASHING_DONE:
      Form5.Memo1.Lines.Add(FileName + '  ... Done!');

    -1,-4,-5,-6,-7,-8,-9,-10,-12,-13:
      Form5.Memo1.Lines.Add('>>> Error code:  ' + IntToStr(StatusCode));
  end;

  Form5.Label14.Text := Format(XH_GENERATESTATUS, [FileCounted, TotalFiles]);

  ProcessMessages;
  Result := CancelAll;
end;


BLACKFIRE69 14-01-2023 11:08

Quote:

Originally Posted by Carldric Clement (Post 499783)
Nothing happen to see the Memo and also the Label which is quite on progressing hash generated on Delphi FMX. But the result works fine. :)

Generate with the directory
...


XHashNext lib for Inno does not work on Delphi. ;)

try this one.

PS: i haven't implemented error levels(StatusCode) in the callback functions for this example. you can add them to your project later.


.

BLACKFIRE69 14-01-2023 23:53

Quote:

Originally Posted by BLACKFIRE69 (Post 499791)
XHashNext lib for Inno does not work on Delphi. ;)

try this one.

@Carldric Clement

sorry, i forgot to mention that you can also use the Inno library for Delphi if the callback functions are method pointers.

this is the example...

.

BLACKFIRE69 15-01-2023 02:55

Update - XHashNext + ChecksumXNext
 
Update available!


Reason: Link


check the first post...

Carldric Clement 27-01-2023 08:37

Quote:

Originally Posted by BLACKFIRE69 (Post 499797)
@Carldric Clement

sorry, i forgot to mention that you can also use the Inno library for Delphi if the callback functions are method pointers.

this is the example...

.

can you update your DLL file? my AV detect was a virus. :)
and second, though I've tried many times to make it works with Unit 2. But unfortunately, some labels and progress bar doesn't work on unit 2 using Inno Library which case Form 2 or something that are callback functions. So I'll be hanging these DLLs cause works with a few Forms that I've made before.

Karekas 30-03-2023 13:32

code for inno script, for newbie
 
Quote:

Originally Posted by BLACKFIRE69 (Post 487767)
XHash Update 1.1v

  • Added more Algos.

    - md5
    - sha1
    - sha256
    - sha512

  • Fixed some bugs.

_


Hello, this addon is very nice.

I'm a little newbie, and I wanted to know if you could provide the code to display this screen, like the one attached to this post, so I can add it to my installer.

thank you and a big hug from this Brazilian.

BLACKFIRE69 29-07-2023 08:38

XHashEx + ChecksumX - Updates
 
Update available!


Code:

* Updated file search. (Thanks to Cesar82)
* Minor improvements.


Check out the first post.


,

Lord.Freddy 31-07-2023 11:32

Hi @BLACKFIRE69, can you update the xxhash algorithm to the last version :D ?
xxHash v0.8.2

BLACKFIRE69 21-06-2026 05:32

XHashEx v2.0 - Update
 
5 Attachment(s)
XHashEx v2.0
File Hashing & Checksum Verification API for Inno Setup
84 algorithms · multi-threaded · Win32 DLL (32 & 64-bit Windows) · by BLACKFIRE69

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━

▌ OVERVIEW
XHashEx is a lightweight, high-performance hashing library crafted for Inno Setup. It generates and verifies checksum files for entire folders, hashes single files, and exposes 84 hashing algorithms — from fast CRC32/XXHash to the full cryptographic suite (SHA-2, SHA-3, BLAKE2/3 …) — all from a single DLL with live per-file and overall progress tracking. Ideal for verifying the integrity of downloaded payloads, large data sets, or already-installed files before continuing an installation.

▌ TECHNICAL SPECIFICATIONS
  • Version — v2.0
  • Author — BLACKFIRE69
  • Build — 2026-Jun
  • Compatibility — Inno Setup v6.0 or later (Required)
  • Platform — Win32 DLL (runs on 32-bit and 64-bit Windows)

▌ WHAT'S NEW (v2.0)

⚠ BREAKING CHANGE — No Backward Compatibility
Every exported function was renamed with an XH_ prefix and a cleaner name (e.g. CalculateHashesForDirXH_GenerateDir). v1.x scripts will not work until imports are updated — swap to the bundled XHashEx.iss header. The ProcessMessages export was removed entirely; the DLL pumps the message queue itself.

✦ Multi-Threading Support (NEW)
Hash many files in parallel via a worker-thread pool, count selectable at runtime with XH_SetThreadCount (XH_THREADS_SINGLE / N / XH_THREADS_AUTO). OFF by default — opt in with one call.

✦ Light Callback Mode (NEW)
On folders with tens of thousands of files, per-file callback crossings into Pascal Script dominate the runtime, not the hashing. XH_SetCallbackMode(XH_CALLBACK_LIGHT) keeps directory runs fast in BOTH thread modes: failures/missing/final file are always reported, plus a ~10×/s sampled tick — the log still records every file. OFF by default.

✦ Measured Performance (28,036 files · xxHash32 · SATA SSD · Windows 11)
Code:

╭───────────────────┬──────────────────────┬──────────────┬───────────╮
│ Mode              │ Duration v1.4+ (Mar) │ Duration 2.0 │ Speedup  │
├───────────────────┼──────────────────────┼──────────────┼───────────┤
│ ST generation    │        7 min 32 sec │      32 sec~14×      │
│ ST verification  │        8 min 40 sec │      35 sec~15×      │
│ MT generation    │        5 min 36 sec │      26 sec~13×      │
│ MT verification  │        6 min 13 sec │      28 sec~13×      │
╰───────────────────┴──────────────────────┴──────────────┴───────────╯

At that rate the SATA SSD itself is the limit (~420–500 MB/s); NVMe raises the ceiling further.

✦ Byte-Weighted Progress (NEW)
Overall progress reflects the share of BYTES hashed, so the bar moves smoothly even when file sizes vary wildly. Toggle with XH_SetProgressMode (on by default).

✦ Accurate MT Progress + Instant Pause
In MT runs the overall percent tracks exactly what's reported to your callback — it reaches 100% precisely when the run finishes — and Pause/Resume/Cancel take effect immediately even under heavy load.

✦ Significant Performance Improvements
Throughput scales with cores (auto-capped to keep disk access sane), no extra per-file metadata pass before hashing, each worker reuses its hash object across files, and the DLL pumps the message queue itself.

✦ New High-Performance File Search Engine
The old file-search code is replaced with a faster wide-API scanner customized for hashing (lean path-only mode), pre-compiled wildcard masks, and full case-insensitive $"regex" support.

✦ Expanded Algorithm Set
The full cryptographic suite is now exposed — 80+ algorithms total (added SHA-224/384, SHA-3/Keccak, RIPEMD-160/320, WhirlPool, BLAKE2B/2SP/2BP, GOST, Snefru, Tiger/Haval variants …).

✦ Unicode Fixes
Checksum and log files are written/read as UTF-8, so non-Latin file names (Cyrillic, CJK …) round-trip correctly instead of being mangled.

✦ Performance Upgrade
Read buffer and hash object reused across files (no per-file alloc), files opened once with sequential-scan I/O, and progress callbacks throttled to whole-percent changes.

✦ Bug Fixes & Stability
Fixed a UI-freeze regression during long operations, corrected progress reporting on the verification path, and various smaller fixes.

✦ Refreshed Example & Docs
A new, comprehensive Inno Setup 6 demo (XHashEx_Example.iss) with a Multi-threaded toggle (paired with light callback mode), a live Elapsed / Speed / ETA readout, and a final Duration + average-throughput summary — plus an updated quick-reference.

▌ KEY FEATURES

✦ Directory Checksum Generation
Recursively hash an entire folder into a single checksum file (.md5/.sha1/.sha256/.sfv …), one algorithm per run.

✦ Checksum Verification
Verify files against a checksum file with an explicit algorithm, or in auto-detect mode (CRC32/MD5/SHA1/SHA256/SHA512) for mixed-algorithm lists.

✦ Single-File Hashing
Compute and return the digest of one file, or verify it against a known hash.

✦ Powerful File Selection (Masks)
Include/Exclude using wildcards, sub-folders, @list files, and case-insensitive $"regex" patterns — mix freely with '|'.

✦ Multi-Threaded Hashing
Optionally hash in parallel across a worker-thread pool (selectable count, or auto). Result callbacks stay on your calling thread — safe to enable with no other code changes.

✦ Live Progress Tracking
Per-file %, overall % (byte-weighted by default), file size, bytes processed, total file count, per-file status (Ok / Bad / Missing).

✦ Process Control
Pause, Resume, and Stop a running operation safely at any point.

✦ Customizable Logging
Optional log file with fully customizable log message strings.

✦ Checksum File Comments
Write custom comment lines into the header of the generated checksum file.

✦ Attribute Control
Optionally include hidden and/or system files when scanning.

✦ Performance Tuning
Adjustable read buffer (default 4 MB) for max throughput on very large files; hash object + buffer reused across files.

✦ Full Unicode Support
Non-Latin file names handled correctly; checksum and log files written as UTF-8.

✦ Previous-Hash Cache
Append new results to existing in-memory hashes to build cumulative checksum files across multiple passes.

✦ Bonus: File Search / Enumeration API
A built-in wide-API file scanner (wfs_*) for listing files/directories by the same mask/regex syntax, with optional per-file size, attributes, and CRC32.

▌ SUPPORTED ALGORITHMS (80+ total)
Code:

╭───────────────────┬──────────────────────────────────────────────────────╮
│ Group            │ Algorithms                                          │
├───────────────────┼──────────────────────────────────────────────────────┤
Checksum          │ CRC32                                                │
MD                │ MD2, MD4, MD5                                        │
SHA-1 / SHA-2    │ SHA0, SHA1, SHA-224/256/384/512, SHA-512/224, /256  │
SHA-3 / Keccak    │ SHA3-224/256/384/512, Keccak-224/256/288/384/512    │
RIPEMD            │ RIPEMD, RIPEMD-128/160/256/320                      │
BLAKE            │ BLAKE2S, BLAKE2B, BLAKE2SP, BLAKE2BP, BLAKE3        │
Tiger            │ Tiger & Tiger2 (3/4/5 rounds x 128/160/192)          │
Haval            │ Haval (3/4/5 rounds x 128/160/192/224/256)          │
Other crypto      │ WhirlPool, GOST, GOST R 34.11-2012, HAS-160, Snefru, │
│                  │ Grindahl, Panama, RadioGatun                        │
Fast / non-crypto │ MurmurHash3, XXHash32                                │
╰───────────────────┴──────────────────────────────────────────────────────╯

Each algorithm has a numeric id (1..84), listed with XH_* constants in XHashEx.iss. Auto-detect verification supports only CRC32/MD5/SHA1/SHA256/SHA512; others need their explicit id.

▌ MASKS (Include / Exclude)
Matched against the file's RELATIVE path + name, combined with '|'. Blank or '*' means all files.
Code:

*.dll|*.exe                  wildcards / extensions
images\png\*                a sub-folder
G????info.*                  ? = single char
@"IncludeFiles.txt"          @list file (one mask per line)
$"^setup.*\.exe$"            case-insensitive regex
*.dll|@list.txt|$"\d{4}"    mix all three

▌ EXPORTED API FUNCTIONS
(v1.x names in parentheses)
  • Generation — XH_GenerateDir (CalculateHashesForDir), XH_GenerateDirEx, XH_HashFile (CalculateFileHash)
  • Verification — XH_VerifyDir (VerifyHashesFromFile), XH_VerifyDirEx, XH_VerifyDirAuto, XH_VerifyDirAutoEx, XH_VerifyFile
  • Process Control — XH_Pause, XH_Resume, XH_Stop, XH_GetStatus
  • Configuration — XH_SetThreadCount, XH_SetCallbackMode, XH_SetProgressMode, XH_SetMaxProgress, XH_SetBufferSize, XH_GetBufferSize, XH_SetIncludeAttribs, XH_SetLogFile, XH_SetLogMessage, XH_HideComments, XH_AddComment, XH_ClearComments
  • Results & Logging — XH_GetLog, XH_ClearLog, XH_GetHashText, XH_ClearHashText, XH_GetVerifiedFileCount
  • Utility — XH_ByteOrTb
  • File Search (wfs_*) — wfs_FindFiles / wfs_FindFilesEx / wfs_FindFilesExFast, wfs_FileCount, wfs_PickFile, wfs_PickFileList, wfs_DirCount, wfs_PickDir, wfs_SaveFileList, wfs_SaveDirList, wfs_FindFree

▌ QUICK START EXAMPLES

Example 1 — Generate a checksum file for a folder
Code:

#include "XHashEx.iss"

function MyProgress(FileName: WideString; FileSize: Extended;
  FileProgress, TotalProgress, TotalFiles, FileCounted, StatusCode: Integer): Boolean;
begin
  // update your UI here ... (no ProcessMessages needed)
  Result := False// return True to abort
end;

if XH_GenerateDir(
    ExpandConstant('{app}\checksums.sha256'),
    ExpandConstant('{app}'),
    XH_SHA256, @MyProgress) = XH_PROCESS_DONE then
  Log('Checksum file created.');

Example 2 — Verify a checksum file
Code:

case XH_VerifyDir(
      ExpandConstant('{app}\checksums.sha256'),
      ExpandConstant('{app}'),
      XH_SHA256, 0, True, @MyProgress) of
  XH_PROCESS_DONE:          Log('All files verified.');
  XH_INVALID_CHECKSUM_FILE: Log('Checksum file missing/invalid.');
  XH_PROCESS_ABORTED:      Log('Cancelled by user.');
end;

Example 3 — Verify a mixed-algorithm list (auto-detect)
Code:

// auto-detect handles CRC32/MD5/SHA1/SHA256/SHA512
XH_VerifyDirAuto(
  ExpandConstant('{app}\hash_mixed.md5'),
  ExpandConstant('{app}'),
  0, False, @MyProgress);  // PreviousFileCount, no log file

Example 4 — Hash a single file
Code:

Digest := XH_HashFile(
  ExpandConstant('{app}\game.exe'), XH_XXHASH_32, @MySingleProgress);
MsgBox('XXHash32: ' + Digest, mbInformation, MB_OK);

Example 5 — Generate with masks (wildcards + regex), hidden files included
Code:

XH_SetIncludeAttribs(True, False);  // include hidden, not system
XH_SetBufferSize(4096);              // 4 MB read buffer

XH_GenerateDirEx(
  ExpandConstant('{app}\data.md5'),
  ExpandConstant('{app}'),
  '*.dll|*.exe|$"^data\d+\.bin$"',    // include masks
  '*.log|$"\.(tmp|bak)$"',            // exclude masks
  True, False, XH_MD5, @MyProgress);

▌ DISTRIBUTION FILES
  • XHashEx.dll — the hashing library (single DLL)
  • XHashEx.iss — header for Inno Setup (constants, types, imports)
  • XHashEx_Example.iss — full working demo (generate / verify / single file, algorithm picker, masks, pause/resume, log)
  • _Usage.txt — quick reference for masks and algorithm ids

▌ Download

- Check the first post.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━

Feedback, bug reports and suggestions are welcome. Enjoy!
— BLACKFIRE69


.


All times are GMT -7. The time now is 21:00.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com