Calculate & compare hashes

Discuss and share scripts and script files...
Posts: 7386
Joined: 06 Feb 2011 00:33

Calculate & compare hashes

Postby highend » 13 Jul 2018 12:56

I often need to compare file hashes with one / many, posted on the website where the file(s) is / are downloaded from.
To make this efficient I wrote this little script...

When invoked without any hashes in the clipboard, it looks like this:
no clp.png
no clp.png (7.1 KiB) Viewed 165 times

You can calculate all (md5, sha1, sha256, sha512, crc32/xxh32) checksum(s) for all selected files
or a specific hash (Calculate <hash>) or compare it with a hash (that you need to enter / paste into
the input box after choosing any of these options).

It looks like this, if the clipboard contains any hashes:
clp.png (6.5 KiB) Viewed 165 times

If you have any arbitrary text in the clipboard, e.g. you've copied the whole text from
to make sure that your downloaded "" file has the correct checksum,
the script will scan the clipboard for matching checksums in the order of the value
from the .ini file: Preferred_Hash_Order=md5|sha512|sha256|sha1|crc32
(You are free to adapt that to your requirements!)

A very convenient way to check if the hash for a file is correct...

Btw, there are a lot of options that you can define in the .ini file!

I'm attaching xxhsum.exe as well. You need to modify the .ini after the script was
launched at least once to adapt the path for it (XXH_Sum_32_Exe=) and if you
want to use it at all (Use_XXH_Sum_32=). If you use it, it will replace! the CRC32
hash option... Why that? Because they both generate 8 chars long values and it's
impossible to know if it is crc32 or xxh32.

If you don't know xxh32:
It is a very! fast non-cryptographic hash algorithm!

Some values from my PC (2 GB test file from a ram disk, 10 rounds):

Code: Select all

xxh32 vs. md5 = ~5-6x faster
xxh32 vs. sha1 = ~5-6x faster
xxh32 vs. sha256 = ~13x faster
xxh32 vs. sha512 = ~9-10x faster
xxh32 vs. crc32 = ~13x faster

This xxhsum.exe was developed in PureBasic, not in C like the one from the
github link. It operates at exactly the same speed!


Code: Select all

xxhsum.exe "R:\BASH Programming Course.iso"

Code: Select all

BASH Programming Course.iso, bytes

Code: Select all

8f213edd|01070.80 ms|R:\BASH Programming Course.iso

While the C version outputs this:

Code: Select all

    $start = now("msecs");
    $hash = runret("""R:\xxhsum.exe"" -H0 ""R:\BASH Programming Course.iso""");
    status "Hash: " . gettoken($hash, 1, " ") . " | Time: " . now("msecs") - $start . " msecs";

Code: Select all

Hash: 8f213edd | Time: 1094 msecs

Current version:
Calculate & compare hashes v0.1.xys
(9.56 KiB) Downloaded 25 times
(35.86 KiB) Downloaded 18 times
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Return to “Script Exchange”

Who is online

Users browsing this forum: No registered users and 1 guest