Click here to Skip to main content
12,547,922 members (49,474 online)
Click here to Skip to main content
Add your own
alternative version


115 bookmarked

ReHash - A console-based hash calculator

, 11 Apr 2003
Rate this:
Please Sign up or sign in to vote.
A console-based hash calculator. Supported algorithms: CRC-16, CRC-16-CCITT, CRC-32, FCS-16, FCS-32, GHash-32-3, GHash-32-5, GOST-Hash, HAVAL-5-256, MD2, MD4, MD5, SHA-1, SHA-256, SHA-384, SHA-512, Tiger.
<!-- Article image -->

Sample Image - rehash.jpg

<!-- Add the rest of your HTML here -->



ReHash is a free, open source console-based hash calculator.

You can disable hash algorithms selectively per command-line if you don't need or like them, you can choose if you want to use recursive directory scanning or not.

This tool is ideal for webmasters who wish to provide their users hash values of their (downloadable) files. The complete hashing process can be automated by using a shell/batch script. No additional user interaction is needed (i.e. the program won't ask for anything, it's just using the command-line).

ReHash is distributed under the terms of the GNU General Public License v2.

Supported algorithms

The current version of ReHash supports the following hash algorithms:

Hash Digest Size
16 bits
16 bits
CRC-32 ANSI X3.66, FIPS PUB 71  
32 bits
16 bits
32 bits
GHash (GHash-32-3, GHash-32-5) - -
32 bits
GOST-Hash R 34.11-94  
256 bits
HAVAL (5 passes, 256 bits)   Zheng, Pieprzyk,
256 bits
MD2 RFC 1319 Rivest
128 bits
MD4 RFC 1320 Rivest
128 bits
MD5 RFC 1321 Rivest
128 bits
160 bits
SHA-2 (SHA256/SHA384/SHA512)   NIST/NSA
256/384/512 bits
SizeHash-32 - -
32 bits
Tiger   Anderson, Biham
192 bits


rehash.exe [options] filespec [> outputfile]

The command-line is parsed from the left to the right. So if you execute ReHash like this:
rehash.exe -all -none *.*
it will output nothing, because you first activate all algorithms and then deactivate them all.

Some usage examples:

Hash all INI files in C:\Windows (including subdirectories) using all hash algorithms:
rehash.exe C:\Windows\*.ini

Hash all INI files in C:\Windows (excluding subdirectories) using all hash algorithms:
rehash.exe -norecur C:\Windows

Hash all BAT files on C:\ (including subdirectories) using only MD5 and SHA-1 (remember command-line is parsed from the left to the right):
rehash.exe -none -md5 -sha1 C:\*.bat

Hash all files in C:\Temp (excluding subdirectories) using only the GOST algorithm:
rehash.exe -norecur -none -gost C:\Temp\*

Hash all ZIP files in C:\homepage (including subdirectories) using only the MD5 algorithm and output the hashes to C:\homepage\downloads\hashes.txt:
rehash.exe -none -md5 C:\homepage\*.zip > C:\homepage\downloads\hashes.txt

All options:

-help / -h / -?/
-version / -v
Print some information about ReHash.
-fullpath / -f Output the full paths of hashed files.
-nopath Just output the filenames of hashed files, not the full paths to the files.
-rcrsv / -recur / -r Recursive scanning. Scan all files in the specified path including files in subdirectories.
-norcrsv / -norecur Disable recursive scanning. Scan only the files in the specified path not including subdirectories.
-all / -a Enable all algorithms.
-none / -n Disable all algorithms.
-crc16 / -nocrc16 Enable/disable the CRC-16 algorithm.
-crc16c / -nocrc16c Enable/disable the CRC-16-CCITT algorithm.
-crc32 / -nocrc32 Enable/disable the CRC-32 algorithm.
-fcs16 / -nofcs16 Enable/disable the FCS-16 algorithm.
-fcs32 / -nofcs32 Enable/disable the FCS-32 algorithm.
-ghash3 / -noghash3 Enable/disable the GHash-3 algorithm.
-ghash5 / -noghash5 Enable/disable the GHash-5 algorithm.
-gost / -nogost Enable/disable the GOST-Hash algorithm.
-haval / -nohaval Enable/disable the HAVAL-5-256 algorithm.
-md2 / -nomd2 Enable/disable the MD2 algorithm.
-md4 / -nomd4 Enable/disable the MD4 algorithm.
-md5 / -nomd5 Enable/disable the MD5 algorithm.
-sha1 / -nosha1 Enable/disable the SHA-1 algorithm.
-sha256 / -nosha256 Enable/disable the SHA-256 algorithm.
-sha384 / -nosha384 Enable/disable the SHA-384 algorithm.
-sha512 / -nosha512 Enable/disable the SHA-512 algorithm.
-size32 / -nosize32 Enable/disable the Size-32 algorithm (simply the byte-count of the message).
-tiger / -notiger Enable/disable the TIGER algorithm.

Thanks / acknowledgements

Thanks to (no particular order):
  • Markku-Juhani O. Saarinen - GOST-Hash implementation
  • Yuliang Zheng - HAVAL implementation
  • Wei Dai - implementations of various algorithms
  • Dr Brian Gladman - SHA-1/SHA-2 implementation
  • Tom St Denis - Tiger implementation


  • 12 April 2003 - v1.0
    First public release


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Dominik Reichl
Software Developer
Germany Germany
Dominik started programming in Omikron Basic, a programming language for the good old Atari ST. After this, there was some short period of QBasic programming on the PC, but soon he began learning C++, which is his favorite language up to now.

Today, his programming experience includes C / C++ / [Visual] C++ [MFC], C#/.NET, Java, JavaScript, PHP and HTML and the basics of pure assembler.

He is interested in almost everything that has to do with computing, his special interests are security and data compression.

You can find his latest freeware, open-source projects and all articles on his homepage:

You may also be interested in...

Comments and Discussions

QuestionThank you Pin
juankre29-Dec-11 12:12
memberjuankre29-Dec-11 12:12 
Generalsha1 16 bits Pin
wassimznaidi15-May-08 7:35
memberwassimznaidi15-May-08 7:35 
GeneralSHA-0 Pin
Gelly Mazour24-Feb-08 22:57
memberGelly Mazour24-Feb-08 22:57 
GeneralNice work! Pin
Willian.BR7-Feb-08 4:23
memberWillian.BR7-Feb-08 4:23 
QuestionThanks Pin
gamakanna30-Jan-07 23:34
membergamakanna30-Jan-07 23:34 
GeneralDoesn't beat crypto++ Pin
haploid30-Nov-06 2:32
memberhaploid30-Nov-06 2:32 
QuestionMistake in SHA-512 calculation. Pin
patti ashwin17-Nov-06 17:37
memberpatti ashwin17-Nov-06 17:37 
Questionwhat is the polynomial used in the CRC-16 algorithm? Pin
PauMs2-Oct-06 12:22
memberPauMs2-Oct-06 12:22 
Generala small bug Pin
waldermort30-Sep-06 21:47
memberwaldermort30-Sep-06 21:47 
GeneralThank you so much Pin
calsurferpunk28-Aug-06 5:28
membercalsurferpunk28-Aug-06 5:28 
GeneralNice work Pin
HatemMostafa24-Mar-06 0:08
memberHatemMostafa24-Mar-06 0:08 
GeneralRe: Nice work Pin
<marquee>ElNoNo15-Aug-06 4:28
memberElNoNo15-Aug-06 4:28 
Generalhelp maual Crypto++ Pin
Anonymous25-Dec-03 0:23
sussAnonymous25-Dec-03 0:23 
Generalneed a way to be able to use this in VB 6 Pin
wtyd66612-May-03 6:19
memberwtyd66612-May-03 6:19 

I really liked this hash calculator. I am a software developer and would appreciate it if I could be able to use this from VB 6. I am only interested in the FCS 16 and FCS 32 algorithms. The problem I am running into is that VB does not support bit shifting and because of this I have to do it manually. But that gives me incorrect CRC values some times. If anyone can point me to something that could do this in VB or be called from VB it would be nice. If anyone can figure out code anomalies that would be nice too. I am attaching my code below.

Thanks in advance.


Option Explicit

Public CRCArray As Variant

Public Function CalcCRC(DataString As String) As String
Dim DataLen As Integer
Dim CRCValue As Long
Dim CRCShiftRight As Integer
Dim X As Integer
Dim NextPieceofData As Integer
Dim CRCShiftRightStr As String
Dim ArrayPointer As Integer
Dim CRCIntStr As String
Dim CRCFinalString As String
Dim CRCletter As String
Dim TempStr As String
Dim CRCShiftRightLONG As Long

DataLen = Len(DataString)
'init variables
CRCShiftRight = 0
ArrayPointer = 0
' Enought potatoes
' fcs = (fcs >> 8) ^ fcstab[(fcs ^ datapiece) & 0xff];
' int CRC to 0xffff
' Loop thru data
For X = 1 To DataLen
NextPieceofData = Asc(Mid(DataString, X, 1))
' SHIFT RIGHT (By turning to Hex movng letters and then back to integer)
CRCShiftRightLONG = CRCValue And &HFF00
'Long to short conversion
If CRCShiftRightLONG < 32767 Then
CRCShiftRight = CRCShiftRightLONG
TempStr = Hex(CRCShiftRight)
TempStr = Hex(CRCShiftRightLONG)
End If
' End Long to short conversion
'Take care of extra or not enough Hex Characters
If Len(TempStr) = 4 Then
CRCShiftRightStr = Mid(TempStr, 1, 2)
If Len(TempStr) = 3 Then
CRCShiftRightStr = Mid(TempStr, 1, 1)
If Len(TempStr) < 3 Then
CRCShiftRightStr = "00"
If Len(TempStr) > 4 Then
CRCShiftRightStr = "00"
Debug.Print "lentempstr error"
End If
End If
End If
End If

'End Take care of extra or not enough Hex Characters

CRCShiftRight = Val("&H" & CRCShiftRightStr)


ArrayPointer = (CRCValue Xor NextPieceofData) And &HFF
'End ArrayPointer

CRCValue = (CRCShiftRight) Xor CRCArray(ArrayPointer)
'End XOR

'Fix neg Numbers
If CRCValue < 0 Then
CRCValue = 65536 + CRCValue
End If
'End Fix Ned Numbers

CRCValue = CRCValue Xor &HFFFF
CRCFinalString = Hex(CRCValue)

Dim HiCRC As String
Dim LoCRC As String
Dim Hi As Byte
Dim Lo As Byte

HiCRC = Hex(CRCValue And &HFF)
Hi = Val("&H" & HiCRC)
LoCRC = Mid(CRCFinalString, 5, 2)
Lo = Val("&H" & LoCRC)

DataString = DataString & Chr(Hi) & Chr(Lo)
CalcCRC = DataString

End Function

Public Sub Init()
CRCArray = Array( _
&H0, &H1189, &H2312, &H329B, &H4624, &H57AD, &H6536, &H74BF0, &H8C48, &H9DC1, &HAF5A, &HBED3, &HCA6C, &HDBE5, &HE97E, &HF8F7, _
&H1081, &H108, &H3393, &H221A, &H56A5, &H472C, &H75B7, &H643E, &H9CC9, &H8D40, &HBFDB, &HAE52, &HDAED, &HCB64, &HF9FF, &HE876, _
&H2102, &H308B, &H210, &H1399, &H6726, &H76AF, &H4434, &H55BD, &HAD4A, &HBCC3, &H8E58, &H9FD1, &HEB6E, &HFAE7, &HC87C, &HD9F5, _
&H3183, &H200A, &H1291, &H318, &H77A7, &H662E, &H54B5, &H453C, &HBDCB, &HAC42, &H9ED9, &H8F50, &HFBEF, &HEA66, &HD8FD, &HC974, _
&H4204, &H538D, &H6116, &H709F, &H420, &H15A9, &H2732, &H36BB, &HCE4C, &HDFC5, &HED5E, &HFCD7, &H8868, &H99E1, &HAB7A, &HBAF3, _
&H5285, &H430C, &H7197, &H601E, &H14A1, &H528, &H37B3, &H263A, &HDECD, &HCF44, &HFDDF, &HEC56, &H98E9, &H8960, &HBBFB, &HAA72, _
&H6306, &H728F, &H4014, &H519D, &H2522, &H34AB, &H630, &H17B9, &HEF4E, &HFEC7, &HCC5C, &HDDD5, &HA96A, &HB8E3, &H8A78, &H9BF1, _
&H7387, &H620E, &H5095, &H411C, &H35A3, &H242A, &H16B1, &H738, &HFFCF, &HEE46, &HDCDD, &HCD54, &HB9EB, &HA862, &H9AF9, &H8B70, _
&H8408, &H9581, &HA71A, &HB693, &HC22C, &HD3A5, &HE13E, &HF0B7, &H840, &H19C9, &H2B52, &H3ADB, &H4E64, &H5FED, &H6D76, &H7CFF, _
&H9489, &H8500, &HB79B, &HA612, &HD2AD, &HC324, &HF1BF, &HE036, &H18C1, &H948, &H3BD3, &H2A5A, &H5EE5, &H4F6C, &H7DF7, &H6C7E, _
&HA50A, &HB483, &H8618, &H9791, &HE32E, &HF2A7, &HC03C, &HD1B5, &H2942, &H38CB, &HA50, &H1BD9, &H6F66, &H7EEF, &H4C74, &H5DFD, _
&HB58B, &HA402, &H9699, &H8710, &HF3AF, &HE226, &HD0BD, &HC134, &H39C3, &H284A, &H1AD1, &HB58, &H7FE7, &H6E6E, &H5CF5, &H4D7C, _
&HC60C, &HD785, &HE51E, &HF497, &H8028, &H91A1, &HA33A, &HB2B3, &H4A44, &H5BCD, &H6956, &H78DF, &HC60, &H1DE9, &H2F72, &H3EFB, _
&HD68D, &HC704, &HF59F, &HE416, &H90A9, &H8120, &HB3BB, &HA232, _
&H5AC5, &H4B4C, &H79D7, &H685E, &H1CE1, &HD68, &H3FF3, &H2E7A, _
&HE70E, &HF687, &HC41C, &HD595, &HA12A, &HB0A3, &H8238, &H93B1, _
&H6B46, &H7ACF, &H4854, &H59DD, &H2D62, &H3CEB, &HE70, &H1FF9, _
&HF78F, &HE606, &HD49D, &HC514, &HB1AB, &HA022, &H92B9, &H8330, _
&H7BC7, &H6A4E, &H58D5, &H495C, &H3DE3, &H2C6A, &H1EF1, &HF78)
End Sub

Generalprova0 Pin
ocean06-May-03 2:04
memberocean06-May-03 2:04 
GeneralCRC algorithms Pin
Tim Smith13-Apr-03 6:09
memberTim Smith13-Apr-03 6:09 
GeneralRe: CRC algorithms Pin
jacques_freedom31-Mar-04 22:10
memberjacques_freedom31-Mar-04 22:10 
GeneralRe: CRC algorithms Pin
Dominik Reichl1-Apr-04 0:19
memberDominik Reichl1-Apr-04 0:19 
GeneralRe: CRC algorithms Pin
Panic2k324-Jan-05 13:34
memberPanic2k324-Jan-05 13:34 
Generalcould be cool but... Pin
Jim Crafton13-Apr-03 5:01
memberJim Crafton13-Apr-03 5:01 
GeneralRe: could be cool but... Pin
Chris Losinger13-Apr-03 6:50
memberChris Losinger13-Apr-03 6:50 
GeneralRe: could be cool but... Pin
Jim Crafton13-Apr-03 11:05
memberJim Crafton13-Apr-03 11:05 
GeneralRe: could be cool but... Pin
Tim Smith14-Apr-03 5:11
memberTim Smith14-Apr-03 5:11 
GeneralUseful... but would like to see a managed code version :-) Pin
Jabes12-Apr-03 5:53
memberJabes12-Apr-03 5:53 
GeneralRe: Useful... but would like to see a managed code version :-) Pin
darkfader9-Jul-03 8:06
sussdarkfader9-Jul-03 8:06 
GeneralRe: Useful... but would like to see a managed code version :-) Pin
Dominik Reichl9-Jul-03 9:47
memberDominik Reichl9-Jul-03 9:47 
GeneralRe: Useful... but would like to see a managed code version :-) Pin
Jabes9-Jul-03 22:49
memberJabes9-Jul-03 22:49 
GeneralRe: Useful... but would like to see a managed code version :-) Pin
LiQuick14-Aug-06 23:19
memberLiQuick14-Aug-06 23:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161021.1 | Last Updated 12 Apr 2003
Article Copyright 2003 by Dominik Reichl
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid