This content has been translated automatically. Click here to view the French version.
• Notes
• Availability of algorithms
WINDEV
WEBDEV
WINDEV Mobile
Others
HashFile (Function)
In french: HashFichier
Calculates the Hash of a file according to a specific algorithm. You have the ability to calculate:
• a simple hash.
• a hash with message authentication.
Reminder: Hashing is used to summarize a file or a character string. This summary is called Hash.
Versions 15 and later
This function is now available for PHP sites.
This function is now available for Java applications.
This function is now available for Android applications.
New in version 15
This function is now available for PHP sites.
This function is now available for Java applications.
This function is now available for Android applications.
This function is now available for PHP sites.
This function is now available for Java applications.
This function is now available for Android applications.
Versions 17 and later
This function is now available for iPhone/iPad applications.
New in version 17
This function is now available for iPhone/iPad applications.
This function is now available for iPhone/iPad applications.
Versions 18 and later
This function is now available in Windows Store apps mode.
This function is now available in Android Widget mode.
New in version 18
This function is now available in Windows Store apps mode.
This function is now available in Android Widget mode.
This function is now available in Windows Store apps mode.
This function is now available in Android Widget mode.
Versions 21 and later
This function is now available in Universal Windows 10 App mode.
New in version 21
This function is now available in Universal Windows 10 App mode.
This function is now available in Universal Windows 10 App mode.
// Calculate the Hash of two files
Hash1 is TO Buffer = HashFile(HA_MD5_128, "C:\My files\FileA.txt")
Hash2 is TO Buffer = HashFile(HA_MD5_128, "D:\My files\FileB.txt")
// Compare the two Hash
IF Hash1 = Hash2 THEN Info("The two files are identical.")
// Calculate the Hash of two files
Hash1 is TO Buffer = HashFile(HA_MD5_128, "\My files\FileA.txt")
Hash2 is TO Buffer = HashFile(HA_MD5_128, "\My files\FileB.txt")
// Compare the two Hash
IF Hash1 = Hash2 THEN Info("The two files are identical.")
Syntax

Calculating a simple hash

<Result> = HashFile(<Type of algorithm> , <File path> [, <Progress Bar>])
<Result>: Buffer
Result of <File path> hashing with the <Type of algorithm> algorithm.
Caution: This result may contain non-displayable characters.
<Type of algorithm>: Integer constant
Indicates the type of algorithm used when hashing the <File path> file:
 Versions 25 and laterMD4 familyNew in version 25MD4 familyMD4 family Versions 25 and laterHA_MD4 Not available.New in version 25HA_MD4 Not available.HA_MD4 Not available.Versions 26 and later This constant is now available.New in version 26 This constant is now available. This constant is now available. MD5 family HA_MD5_128 Versions 24 and laterMURMUR familyNew in version 24MURMUR familyMURMUR family Versions 24 and laterHA_MURMUR_1: Murmur algorithm version 1: 32-bit hash resultNew in version 24HA_MURMUR_1: Murmur algorithm version 1: 32-bit hash resultHA_MURMUR_1: Murmur algorithm version 1: 32-bit hash resultVersions 24 and laterHA_MURMUR_2: Murmur algorithm version 2: 32-bit hash resultNew in version 24HA_MURMUR_2: Murmur algorithm version 2: 32-bit hash resultHA_MURMUR_2: Murmur algorithm version 2: 32-bit hash resultVersions 24 and laterHA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processorsNew in version 24HA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processorsHA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processorsVersions 24 and laterHA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processorsNew in version 24HA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processorsHA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processorsVersions 24 and laterHA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash resultNew in version 24HA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash resultHA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash resultVersions 24 and laterHA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash resultNew in version 24HA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash resultHA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash resultVersions 24 and laterHA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash resultNew in version 24HA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash resultHA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash resultVersions 24 and laterHA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash resultNew in version 24HA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash resultHA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash resultVersions 24 and laterHA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processorsNew in version 24HA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processorsHA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processorsVersions 24 and laterHA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processorsNew in version 24HA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processorsHA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors Vitals for this family are unavailable.Versions 25 and later Now available in PHP.New in version 25 Now available in PHP. Now available in PHP. Vitals for this family are unavailable.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available. RIPEMD family HA_RIPEMD_128HA_RIPEMD_160 Vitals for this family are unavailable. Vitals for this family are unavailable.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available. SHA-1 family HA_SHA_160 (also called SHA-1)HA_SHA_256 (FIPS PUB 198 specifications)Versions 25 and laterHA_SHA_256_DOUBLENew in version 25HA_SHA_256_DOUBLEHA_SHA_256_DOUBLEHA_SHA_384HA_SHA_512 Versions 23 and laterSHA-3 familyNew in version 23SHA-3 familySHA-3 family Versions 23 and laterHA_SHA3_224New in version 23HA_SHA3_224HA_SHA3_224Versions 23 and laterHA_SHA3_256New in version 23HA_SHA3_256HA_SHA3_256Versions 23 and laterHA_SHA3_384New in version 23HA_SHA3_384HA_SHA3_384Versions 23 and laterHA_SHA3_512New in version 23HA_SHA3_512HA_SHA3_512 Vitals for this family are unavailable.Versions 25 and later Now available in PHP.New in version 25 Now available in PHP. Now available in PHP.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available. TIGER family HA_TIGER_128HA_TIGER_160HA_TIGER_192 Vitals for this family are unavailable. Vitals for this family are unavailable.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available. WHIRLPOOL family HA_WHIRLPOOL Not available. Not available.Versions 26 and later This constant is now available.New in version 26 This constant is now available. This constant is now available. CKSUM family HA_CKSUM_8HA_CKSUM_16HA_CKSUM_32HA_CKSUM_64 Vitals for this family are unavailable. Vitals for this family are unavailable.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available.
• MD4 / MD5 / SHA / RIPEMD algorithms: standard cryptographic hash functions.
• TIGER/WHIRLPOOL algorithms: hash functions with high cryptographic properties optimized for the 64-bit mode (but can also be used in 32-bit mode).
• CKSUM algorithms: hash functions with no cryptographic property, should be used to perform low-level checks or with hashing tables.
• Versions 24 and later
MURMUR algorithm: very fast hash functions with no cryptographic properties. This algorithm is used by the "bloom filter" of bitcoin wallets.
New in version 24
MURMUR algorithm: very fast hash functions with no cryptographic properties. This algorithm is used by the "bloom filter" of bitcoin wallets.
MURMUR algorithm: very fast hash functions with no cryptographic properties. This algorithm is used by the "bloom filter" of bitcoin wallets.
<File path>: Character string (with quotes)
Path of file on which the calculation will be performed.
<Progress Bar>: Optional window name or optional control name
Versions 24 and later
• Name of window where the progress bar will be displayed,
• Name of the Progress Bar control to use.
This parameter is ignored.
New in version 24
• Name of window where the progress bar will be displayed,
• Name of the Progress Bar control to use.
This parameter is ignored.
• Name of window where the progress bar will be displayed,
• Name of the Progress Bar control to use.
This parameter is ignored.

Calculating a hash with message authentication (HMAC/MURMUR algorithm)

<Result> = HashFile(<Type of algorithm> , <File path> , <Secret key> [, <Progress Bar>])
<Result>: Buffer
Result of <File path> hashing with the <Type of algorithm> algorithm.
Caution: This result may contain non-displayable characters.
<Type of algorithm>: Integer constant
Indicates the type of HMAC algorithm used when hashing the <File path> file:
 Versions 25 and laterMD4 familyNew in version 25MD4 familyMD4 family Versions 25 and laterHA_HMAC_MD4 Not available.New in version 25HA_HMAC_MD4 Not available.HA_HMAC_MD4 Not available.Versions 26 and later This constant is now available.New in version 26 This constant is now available. This constant is now available. MD5 family HA_HMAC_MD5_128 Versions 24 and laterMURMUR familyNew in version 24MURMUR familyMURMUR family Versions 24 and laterHA_MURMUR_1: Murmur algorithm version 1: 32-bit hash resultNew in version 24HA_MURMUR_1: Murmur algorithm version 1: 32-bit hash resultHA_MURMUR_1: Murmur algorithm version 1: 32-bit hash resultVersions 24 and laterHA_MURMUR_2: Murmur algorithm version 2: 32-bit hash resultNew in version 24HA_MURMUR_2: Murmur algorithm version 2: 32-bit hash resultHA_MURMUR_2: Murmur algorithm version 2: 32-bit hash resultVersions 24 and laterHA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processorsNew in version 24HA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processorsHA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processorsVersions 24 and laterHA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processorsNew in version 24HA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processorsHA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processorsVersions 24 and laterHA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash resultNew in version 24HA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash resultHA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash resultVersions 24 and laterHA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash resultNew in version 24HA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash resultHA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash resultVersions 24 and laterHA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash resultNew in version 24HA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash resultHA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash resultVersions 24 and laterHA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash resultNew in version 24HA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash resultHA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash resultVersions 24 and laterHA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processorsNew in version 24HA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processorsHA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processorsVersions 24 and laterHA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processorsNew in version 24HA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processorsHA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors Vitals for this family are unavailable.Versions 25 and later Now available in PHP.New in version 25 Now available in PHP. Now available in PHP. Vitals for this family are unavailable.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available. RIPEMD family HA_HMAC_RIPEMD_128HA_HMAC_RIPEMD_160 Vitals for this family are unavailable. Vitals for this family are unavailable.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available. SHA family HA_HMAC_SHA_160HA_HMAC_SHA_256 Versions 25 and laterHA_HMAC_SHA_256_DOUBLENew in version 25HA_HMAC_SHA_256_DOUBLEHA_HMAC_SHA_256_DOUBLEHA_HMAC_SHA_384HA_HMAC_SHA_512 Versions 23 and laterSHA-3 familyNew in version 23SHA-3 familySHA-3 family Versions 23 and laterHA_HMAC_SHA3_224New in version 23HA_HMAC_SHA3_224HA_HMAC_SHA3_224Versions 23 and laterHA_HMAC_SHA3_256New in version 23HA_HMAC_SHA3_256HA_HMAC_SHA3_256Versions 23 and laterHA_HMAC_SHA3_384New in version 23HA_HMAC_SHA3_384HA_HMAC_SHA3_384Versions 23 and laterHA_HMAC_SHA3_512New in version 23HA_HMAC_SHA3_512HA_HMAC_SHA3_512 Vitals for this family are unavailable.Versions 25 and later Now available in PHP.New in version 25 Now available in PHP. Now available in PHP.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available. TIGER family HA_HMAC_TIGER_128HA_HMAC_TIGER_160HA_HMAC_TIGER_192 Vitals for this family are unavailable. Vitals for this family are unavailable.Versions 26 and later The constants of this family are now available.New in version 26 The constants of this family are now available. The constants of this family are now available. WHIRLPOOL family HA_HMAC_WHIRLPOOL Not available. Not available.Versions 26 and later This constant is now available.New in version 26 This constant is now available. This constant is now available.
• MD4 / MD5 / SHA / RIPEMD algorithms: standard cryptographic hash functions.
• TIGER/WHIRLPOOL algorithms: hash functions with high cryptographic properties optimized for the 64-bit mode (but can also be used in 32-bit mode).
• Versions 24 and later
MURMUR algorithm: very fast hash functions with no cryptographic properties. This algorithm is used by the "bloom filter" of bitcoin wallets.
New in version 24
MURMUR algorithm: very fast hash functions with no cryptographic properties. This algorithm is used by the "bloom filter" of bitcoin wallets.
MURMUR algorithm: very fast hash functions with no cryptographic properties. This algorithm is used by the "bloom filter" of bitcoin wallets.
<File path>: Character string (with quotes)
Path of file on which the calculation will be performed.
<Secret key>: Character string (between quotes) or Integer
Authentication key of message.
• If an HMAC algorithm is used, this parameter must be a string.
• Versions 24 and later
If a MURMUR algorithm is used, the key must be an integer.
New in version 24
If a MURMUR algorithm is used, the key must be an integer.
If a MURMUR algorithm is used, the key must be an integer.
This parameter must not be an empty string.
<Progress Bar>: Optional control name or optional window name
Versions 24 and later
• Name of window where the progress bar will be displayed,
• Name of the Progress Bar control to use.
This parameter is ignored.
New in version 24
• Name of window where the progress bar will be displayed,
• Name of the Progress Bar control to use.
This parameter is ignored.
• Name of window where the progress bar will be displayed,
• Name of the Progress Bar control to use.
This parameter is ignored.
Remarks

Notes

• Two files with an identical content will have, for the same type of algorithm, two identical Hashes.
• The result of the Hash may contain non-displayable characters. These characters will not be visible when using Info or Trace for example.

Availability of algorithms

Algorithms are available depending on the PHP server configuration ('mhash' extension, PHP 5 with native hash function, etc).
Only the following algorithms are supported :
• HA_HMAC_MD5_128
• HA_HMAC_SHA_160, HA_HMAC_SHA_256, HA_HMAC_SHA_384, HA_SHA_HMAC_512
• Versions 25 and later
HA_HMAC_SHA_256_DOUBLE
New in version 25
HA_HMAC_SHA_256_DOUBLE
HA_HMAC_SHA_256_DOUBLE
• Versions 25 and later
HA_MD4
New in version 25
HA_MD4
HA_MD4
• HA_MD5_128
• HA_SHA_160, HA_SHA_256, HA_SHA_384, HA_SHA_512
• Versions 25 and later
HA_SHA_256_DOUBLE
New in version 25
HA_SHA_256_DOUBLE
HA_SHA_256_DOUBLE
Related Examples:
 Unit examples (WINDEV): The Hash functions [ + ] Using the hashing functions.The HashFile and HashString functions are used to calculate a Hash key for a string or for a file.This Hash key is used to: - Check whether the file is consistent after a transfer for example- Find file duplicates - ...