• 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: The 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 the PHP sites.
This function is now available for the Java applications.
This function is now available for the Android applications.
New in version 15
This function is now available for the PHP sites.
This function is now available for the Java applications.
This function is now available for the Android applications.
This function is now available for the PHP sites.
This function is now available for the Java applications.
This function is now available for the Android applications.
Versions 17 and later
This function is now available for the iPhone/iPad applications.
New in version 17
This function is now available for the iPhone/iPad applications.
This function is now available for the 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 Buffer = HashFile(HA_MD5_128, "C:\My files\FileA.txt")
Hash2 is 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 Buffer = HashFile(HA_MD5_128, "\My files\FileA.txt")
Hash2 is 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>)
<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:
 MD5 family HA_MD5_128 SHA family HA_SHA_160 (also called SHA-1) HA_SHA_256 HA_SHA_384 HA_SHA_512 Versions 23 and laterSHA-3 familyNew in version 23SHA-3 familySHA-3 family Versions 23 and laterHA_SHA3_224 Not available.New in version 23HA_SHA3_224 Not available.HA_SHA3_224 Not available. Versions 23 and laterHA_SHA3_256 Not available.New in version 23HA_SHA3_256 Not available.HA_SHA3_256 Not available. Versions 23 and laterHA_SHA3_384 Not available.New in version 23HA_SHA3_384 Not available.HA_SHA3_384 Not available. Versions 23 and laterHA_SHA3_512 Not available.New in version 23HA_SHA3_512 Not available.HA_SHA3_512 Not available. RIPEMD family HA_RIPEMD_128 Not available. HA_RIPEMD_160 Not available. TIGER family HA_TIGER_128 Not available. Not available. HA_TIGER_160 Not available. Not available. HA_TIGER_192 Not available. Not available. WHIRLPOOL family HA_WHIRLPOOL Not available. CKSUM family HA_CKSUM_8 Not available. HA_CKSUM_16 Not available. HA_CKSUM_32 Not available. HA_CKSUM_64 Not available.
• 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).
The TIGER algorithms are not available.
• CKSUM algorithms: hash functions with no cryptographic property, should be used to perform low-level checks or with hashing tables.
<File Path>: Character string (with quotes)
Path of file on which the calculation will be performed.

Calculating a hash with message authentication (HMAC algorithm)

<Result> = HashFile(<Type of Algorithm> , <File Path> , <Secret Key>)
<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:
 MD5 family HA_HMAC_MD5_128 SHA family HA_HMAC_SHA_160 HA_HMAC_SHA_256 HA_HMAC_SHA_384 HA_HMAC_SHA_512 Versions 23 and laterSHA-3 familyNew in version 23SHA-3 familySHA-3 family Versions 23 and laterHA_SHA3_224 Not available.New in version 23HA_SHA3_224 Not available.HA_SHA3_224 Not available. Versions 23 and laterHA_SHA3_256 Not available.New in version 23HA_SHA3_256 Not available.HA_SHA3_256 Not available. Versions 23 and laterHA_SHA3_384 Not available.New in version 23HA_SHA3_384 Not available.HA_SHA3_384 Not available. Versions 23 and laterHA_SHA3_512 Not available.New in version 23HA_SHA3_512 Not available.HA_SHA3_512 Not available. RIPEMD family HA_HMAC_RIPEMD_128 Not available. HA_HMAC_RIPEMD_160 Not available. TIGER family HA_HMAC_TIGER_128 Not available. Not available. HA_HMAC_TIGER_160 Not available. Not available. HA_HMAC_TIGER_192 Not available. Not available. WHIRLPOOL family HA_HMAC_WHIRLPOOL Not available.
• 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).
The TIGER algorithms are not available.
<File Path>: Character string (with quotes)
Path of file on which the calculation will be performed.
<Secret Key>: Character string (with quotes)
Authentication key of message.
This parameter must not be an empty string.
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

• The available algorithms depend on the configuration of the PHP server.
• The TIGER algorithms are not available.The SHA-3 algorithms are not available.
Only the following algorithms are supported:
• HA_MD5_128
• HA_SHA_160, HA_SHA_256, HA_SHA_384, HA_SHA_512
• HA_HMAC_MD5_128
• HA_ HMAC_SHA_160, HA_HMAC_SHA_256, HA_HMAC_SHA_384, HA_SHA_HMAC_512.
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 - ...
Components
wd230com.dll
wp230com.dll
wd230java.jar
wd230com.so
wd230android.jar
Minimum required version
• Version 11