ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Hash functions
  • Notes
  • HashString and UNICODE
  • Availability of algorithms
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Calculates the Hash of a character string according to a specific algorithm. You have the ability to calculate:
  • a simple hash.
  • a hash with message authentication.
  • a hash obtained with a key derivation function that takes a salt as parameter (PBKDF2).
    WEBDEV - Browser codeAndroidAndroid Widget JavaPHP Not available.
Reminder Hashing is used to produce a condensed summary of a file or character string. This summary is called Hash.
Caution: Result may contain characters that cannot be displayed. If you want to get a string with the hexadecimal representations of bytes (to use it in a REST or SOAP API, for example) you can use BufferToHexa with the NoGrouping constant on the result buffer.
WindowsLinuxAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystJavaPHP
// Calcul du Hash des valeurs de deux champs de saisie
Hash1 is Buffer = HashString(HA_MD5_128, SAI_Saisie1)
Hash2 is Buffer = HashString(HA_MD5_128, SAI_Saisie2)
// Comparaison des deux Hash 
IF Hash1 = Hash2 THEN Info("Les deux chaînes sont identiques.")
WEBDEV - Browser code
HashString(HA_SHA_160, "abc", HashChaîne_Callback)

INTERNAL PROCEDURE HashChaîne_Callback(buffer)
	// Ce code permet de visualiser le buffer
	Trace(BufferToHexa(buffer, NoGrouping))
END
Syntax

Calculating a simple hash Hide the details

<Result> = HashString(<Type of algorithm> , <String>)
<Result>: Buffer
Result of <String> hashing with the <Type of algorithm> algorithm.
<Type of algorithm>: Integer constant
Indicates the type of algorithm used when hashing the <String>:
DJB2 family (Bernstein)
  • HA_DJB2_32
  • HA_DJB2_64
JavaPHP The constants of this family are not available.
MD4 familyHA_MD4
MD5 familyHA_MD5_128
Please note: this type of algorithm is currently deprecated.
MURMUR family
  • HA_MURMUR_1 Murmur algorithm version 1: 32-bit hash result
  • HA_MURMUR_2 Murmur algorithm version 2: 32-bit hash result
  • HA_MURMUR_2_64A Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processors
  • HA_MURMUR_2_64B Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processors
  • HA_MURMUR_2_A Murmur version 2 incremental algorithm: 32-bit hash result
  • HA_MURMUR_2_BIG_ENDIAN Murmur algorithm version 2 for big-endian machine: 32-bit hash result
  • HA_MURMUR_2_ALIGNE Murmur algorithm version 2 for aligned machine: 32-bit hash result
  • HA_MURMUR_3_32 Murmur algorithm version 3: 32-bit hash result
  • HA_MURMUR_3_128_X86 Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processors
  • HA_MURMUR_3_128_X64 Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors
Java The constants of this family are not available.
RIPEMD family
  • HA_RIPEMD_128
  • HA_RIPEMD_160
Java The constants of this family are not available.
SHA family
  • HA_SHA_160 (also called SHA-1)
  • HA_SHA_256 (FIPS PUB 198 specifications)
  • HA_SHA_256_DOUBLE
  • HA_SHA_384
  • HA_SHA_512
SHA-3 family
  • HA_SHA3_224
  • HA_SHA3_256
  • HA_SHA3_384
  • HA_SHA3_512
TIGER family
  • HA_TIGER_128
  • HA_TIGER_160
  • HA_TIGER_192
Java The constants of this family are not available.
WHIRLPOOL familyHA_WHIRLPOOL
Java Not available.
CKSUM family
  • HA_CKSUM_8
  • HA_CKSUM_16
  • HA_CKSUM_32
  • HA_CKSUM_64
Java The constants of this family are not available.
  • MD4 / MD5 / SHA / RIPEMD algorithms: classic cryptographic hash functions.
  • TIGER / WHIRLPOOL algorithms: hash functions with very good cryptographic properties, optimized for 64-bit (but can be used in 32-bit).
  • CKSUM algorithms: hash functions with no cryptographic properties, to be used only for minimal checks or hash tables.
  • DJB2 algorithm (Bernstein): string-only hash functions with no cryptographic properties, to be used only for minimal checks or hash tables. Few risks to get an identical hash.
  • MURMUR algorithm: very fast hash functions with no cryptographic properties. This algorithm is used by the "bloom filter" of bitcoin wallets.
<String>: Character string
String on which the calculation will be performed. This parameter can contain binary characters.
WEBDEV - Browser code

Calculating a simple hash Hide the details

HashString(<Type of algorithm> , <String> , <WLanguage procedure>)
<Type of algorithm>: Integer constant
Indicates the type of algorithm used when hashing the <String>:
SHA family
  • HA_SHA_160 (also called SHA-1)
  • HA_SHA_256 (FIPS PUB 198 specifications)
  • HA_SHA_256_DOUBLE
  • HA_SHA_384
  • HA_SHA_512

Remarks:
  • These hash algorithms are not allowed in Internet Explorer.
  • The HA_SHA_160 algorithm is not allowed in Edge.
<String>: Character string
String on which the calculation will be performed. This parameter can contain binary characters.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called when hashing. This procedure is used to get the hash result. For more details, see Procedure used by HashString.

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

<Result> = HashString(<Type of algorithm> , <String> , <Secret key>)
<Result>: Buffer
Result of <String> hashing with the <Type of algorithm> algorithm. The length of this string depends on the algorithm used. For example, if the HA_HMAC_SHA_256 constant is used, the result will contain 32 bytes.
Warning: this result may contain characters that cannot be displayed.
<Type of algorithm>: Integer constant
Indicates the type of algorithm (HMAC or MURMUR) used to hash the <String>:
MD4 familyHA_HMAC_MD4

MD5 familyHA_HMAC_MD5_128
Please note: this type of algorithm is currently deprecated.
MURMUR family
  • HA_MURMUR_1 Murmur algorithm version 1: 32-bit hash result
  • HA_MURMUR_2 Murmur algorithm version 2: 32-bit hash result
  • HA_MURMUR_2_64A Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processors
  • HA_MURMUR_2_64B Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processors
  • HA_MURMUR_2_A Murmur version 2 incremental algorithm: 32-bit hash result
  • HA_MURMUR_2_BIG_ENDIAN Murmur algorithm version 2 for big-endian machine: 32-bit hash result
  • HA_MURMUR_2_ALIGNE Murmur algorithm version 2 for aligned machine: 32-bit hash result
  • HA_MURMUR_3_32 Murmur algorithm version 3: 32-bit hash result
  • HA_MURMUR_3_128_X86 Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processors
  • HA_MURMUR_3_128_X64 Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors
Java The constants of this family are not available.
RIPEMD family
  • HA_HMAC_RIPEMD_128
  • HA_HMAC_RIPEMD_160
Java The constants of this family are not available.
SHA family
  • HA_HMAC_SHA_160
  • HA_HMAC_SHA_256
  • HA_HMAC_SHA_256_DOUBLE
  • HA_HMAC_SHA_384
  • HA_HMAC_SHA_512
SHA-3 family
  • HA_HMAC_SHA3_224
  • HA_HMAC_SHA3_256
  • HA_HMAC_SHA3_384
  • HA_HMAC_SHA3_512
TIGER family
  • HA_HMAC_TIGER_128
  • HA_HMAC_TIGER_160
  • HA_HMAC_TIGER_192
Java The constants of this family are not available.
WHIRLPOOL familyHA_HMAC_WHIRLPOOL
Java Not available.
  • MD4 / MD5 / SHA / RIPEMD algorithms: classic cryptographic hash functions.
  • TIGER / WHIRLPOOL algorithms: hash functions with very good cryptographic properties, optimized for 64-bit (but can be used in 32-bit).
  • MURMUR algorithm: very fast hash functions with no cryptographic properties. This algorithm is used by the "bloom filter" of bitcoin wallets.
<String>: Character string
String on which the calculation will be performed. This parameter can contain binary characters.
<Secret key>: Character string or Integer or Secret string
Authentication key of message.
  • If an HMAC algorithm is used, this parameter must be a string.
  • If a MURMUR algorithm is used, the key must be an integer.
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter can be:
  • Buffer - ASCII or Buffer - UTF-8,
  • ANSI string - Latin,
  • ANSI or Unicode string,
  • Unicode string.
To learn more about secret strings and how to use the vault, see Secret string vault.
New in version 2025
AndroidAndroid Widget Secret strings are not available for this parameter in Android/Android widget applications.
AndroidAndroid Widget Java This parameter must not be an empty string.
WEBDEV - Browser code

Calculating a hash with message authentication (HMAC algorithm) Hide the details

HashString(<Type of algorithm> , <String> , <Secret key> , <WLanguage procedure>)
<Type of algorithm>: Integer constant
Indicates the type of algorithm (HMAC) used to hash the <String> string:
SHA family
  • HA_HMAC_SHA_160
  • HA_HMAC_SHA_256
  • HA_HMAC_SHA_384
  • HA_HMAC_SHA_512

Remarks:
  • These hash algorithms are not allowed in Internet Explorer.
  • These hash algorithms are not allowed in Edge.
<String>: Character string
String on which the calculation will be performed. This parameter can contain binary characters.
<Secret key>: Character string or Secret string
Authentication key of message.
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter can be:
  • Buffer - ASCII or Buffer - UTF-8,
  • ANSI string - Latin,
  • ANSI or Unicode string,
  • Unicode string.
To learn more about secret strings and how to use the vault, see Secret string vault.
New in version 2025
AndroidAndroid Widget Secret strings are not available for this parameter in Android/Android widget applications.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called when hashing. This procedure is used to get the hash result. For more details, see Procedure used by HashString.
WindowsLinuxiPhone/iPadIOS WidgetMac Catalyst

Calculating a hash using a key derivation function that takes a salt as parameter (PBKDF2) Hide the details

<Result> = HashString(<Type of algorithm> , <String> , <Salt> , <Iteration> , <Length>)
<Result>: Buffer
Result of <String> hashing with the <Type of algorithm> algorithm.
Warning: this result may contain characters that cannot be displayed.. If this result must be displayed, it can be converted by BufferToHexa.
<Type of algorithm>: Integer constant
Specifies the type of pseudo-random algorithm used by PBKDF2 to hash <String>:
MD4 familyHA_PBKDF2_HMAC_MD4
MD5 familyHA_PBKDF2_HMAC_MD5_128
Please note: this type of algorithm is currently deprecated.
RIPEMD family
  • HA_PBKDF2_HMAC_RIPEMD_128
  • HA_PBKDF2_HMAC_RIPEMD_160
SHA family
  • HA_PBKDF2_HMAC_SHA_160
  • HA_PBKDF2_HMAC_SHA_256
  • HA_PBKDF2_HMAC_SHA_256_DOUBLE
  • HA_PBKDF2_HMAC_SHA_384
  • HA_PBKDF2_HMAC_SHA_512
SHA-3 family
  • HA_PBKDF2_HMAC_SHA3_224
  • HA_PBKDF2_HMAC_SHA3_256
  • HA_PBKDF2_HMAC_SHA3_384
  • HA_PBKDF2_HMAC_SHA3_512
TIGER family
  • HA_PBKDF2_HMAC_TIGER_128
  • HA_PBKDF2_HMAC_TIGER_160
  • HA_PBKDF2_HMAC_TIGER_192
WHIRLPOOL familyHA_PBKDF2_HMAC_WHIRLPOOL
  • MD4 / MD5 / SHA / RIPEMD algorithms: classic cryptographic hash functions.
  • TIGER / WHIRLPOOL algorithms: hash functions with very good cryptographic properties, optimized for 64-bit (but can be used in 32-bit).
<String>: Character string
String on which the calculation will be performed. This parameter can contain binary characters.
<Salt>: Character string
Cryptographic salt used. String (usually random) added to the original string to make it more complex. For example, it makes it possible for two users to use the same password.
<Iteration>: Integer
Number of iterations of the algorithm (10000 by default). This number depends on the power of the computing machine and the complexity of the hash. A minimum of 1000 iterations is generally recommended.
<Length>: Integer
Length of the derived key. By default, corresponds to the size of the key generated by the pseudo-random function. This length is technically unbounded but due to the algorithm, it is limited to (2^32 - 1) * (output length of the algorithm used by PBKDF2).
Remarks

Notes

  • Two identical character strings 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.

HashString and UNICODE

  • Caution: Hash functions act at the string byte level. The result for the same type of algorithm will therefore be different in Unicode and ANSI.
  • Cross-platform development To use string hashes across platforms (e.g. a hash generated on iOS and verified on Android or Windows), do not use Unicode strings. Indeed, the Unicode strings do not have the same format according to the platforms. In this case, we advise you to use strings in ANSI or UTF 8 format (and to convert the Unicode strings if necessary).
JavaPHP

Availability of algorithms

PHP Algorithms are available depending on the PHP server configuration ('mhash' extension, PHP 5 with native hash function, etc).
Java 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
  • HA_HMAC_SHA_256_DOUBLE
  • HA_MD4
  • HA_MD5_128
  • HA_SHA_160, HA_SHA_256, HA_SHA_384, HA_SHA_512
  • HA_SHA_256_DOUBLE
Related Examples:
The Hash functions 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
- ...
Business / UI classification: Business Logic
Component: wd300com.dll
Minimum version required
  • Version 11
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/16/2025

Send a report | Local help