PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Notes
  • HashString and UNICODE
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Calculates the Hash of a character string according to a specific algorithm. You can calculate:
  • a simple hash.
  • a hash with message authentication.
  • Versions 27 and later
    a hash obtained with a key derivation function that takes a salt as parameter (PBKDF2).
    New in version 27
    a hash obtained with a key derivation function that takes a salt as parameter (PBKDF2).
    a hash obtained with a key derivation function that takes a salt as parameter (PBKDF2).
Reminder: Hashing is used to summarize a file or a character string. This summary is called Hash.
Windows
// Calculate the Hash of values for two edit controls
Hash1 is Buffer = HashString(HA_MD5_128, EDT_Edit1)
Hash2 is Buffer = HashString(HA_MD5_128, EDT_Edit2)
// Compare the two Hash
IF Hash1 = Hash2 THEN Info("The two strings are identical.")
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.
Caution: this result may contain non-displayable characters. If this result must be displayed, it can be converted by BufferToHexa.
<Type of algorithm>: Integer constant
Indicates the type of algorithm used when hashing the <String>:
Versions 22 and later
DJB2 family (Bernstein)
New in version 22
DJB2 family (Bernstein)
DJB2 family (Bernstein)
  • Versions 22 and later
    HA_DJB2_32
    New in version 22
    HA_DJB2_32
    HA_DJB2_32
  • Versions 22 and later
    HA_DJB2_64
    New in version 22
    HA_DJB2_64
    HA_DJB2_64
Versions 25 and later
MD4 family
New in version 25
MD4 family
MD4 family
Versions 25 and later
HA_MD4
New in version 25
HA_MD4
HA_MD4
MD5 familyHA_MD5_128
Versions 24 and later
MURMUR family
New in version 24
MURMUR family
MURMUR family
  • Versions 24 and later
    HA_MURMUR_1: Murmur algorithm version 1: 32-bit hash result
    New in version 24
    HA_MURMUR_1: Murmur algorithm version 1: 32-bit hash result
    HA_MURMUR_1: Murmur algorithm version 1: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_2: Murmur algorithm version 2: 32-bit hash result
    New in version 24
    HA_MURMUR_2: Murmur algorithm version 2: 32-bit hash result
    HA_MURMUR_2: Murmur algorithm version 2: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processors
    New in version 24
    HA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processors
    HA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processors
  • Versions 24 and later
    HA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processors
    New in version 24
    HA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processors
    HA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processors
  • Versions 24 and later
    HA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash result
    New in version 24
    HA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash result
    HA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash result
    New in version 24
    HA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash result
    HA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash result
    New in version 24
    HA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash result
    HA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash result
    New in version 24
    HA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash result
    HA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processors
    New in version 24
    HA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processors
    HA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processors
  • Versions 24 and later
    HA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors
    New in version 24
    HA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors
    HA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors
RIPEMD family
  • HA_RIPEMD_128
  • HA_RIPEMD_160
SHA family
  • HA_SHA_160 (also called SHA-1)
  • HA_SHA_256 (FIPS PUB 198 specifications)
  • Versions 25 and later
    HA_SHA_256_DOUBLE
    New in version 25
    HA_SHA_256_DOUBLE
    HA_SHA_256_DOUBLE
  • HA_SHA_384
  • HA_SHA_512
Versions 23 and later
SHA-3 family
New in version 23
SHA-3 family
SHA-3 family
  • Versions 23 and later
    HA_SHA3_224
    New in version 23
    HA_SHA3_224
    HA_SHA3_224
  • Versions 23 and later
    HA_SHA3_256
    New in version 23
    HA_SHA3_256
    HA_SHA3_256
  • Versions 23 and later
    HA_SHA3_384
    New in version 23
    HA_SHA3_384
    HA_SHA3_384
  • Versions 23 and later
    HA_SHA3_512
    New in version 23
    HA_SHA3_512
    HA_SHA3_512
TIGER family
  • HA_TIGER_128
  • HA_TIGER_160
  • HA_TIGER_192
WHIRLPOOL familyHA_WHIRLPOOL
CKSUM family
  • HA_CKSUM_8
  • HA_CKSUM_16
  • HA_CKSUM_32
  • HA_CKSUM_64
  • 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 22 and later
    DJB2 algorithm (Bernstein): hash functions reserved to strings and with no cryptographic property, should be used to perform low-level checks or with hashing tables. Few risks to get an identical hash.
    New in version 22
    DJB2 algorithm (Bernstein): hash functions reserved to strings and with no cryptographic property, should be used to perform low-level checks or with hashing tables. Few risks to get an identical hash.
    DJB2 algorithm (Bernstein): hash functions reserved to strings and with no cryptographic property, should be used to perform low-level checks or with hashing tables. Few risks to get an identical hash.
  • 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.
<String>: Character string
String on which the calculation will be performed. This parameter can contain binary characters.

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.
Caution: this result may contain non-displayable characters.
<Type of algorithm>: Integer constant
Indicates the type of algorithm (HMAC or MURMUR) used to hash the <String>:
Versions 25 and later
MD4 family
New in version 25
MD4 family
MD4 family
Versions 25 and later
HA_HMAC_MD4

New in version 25
HA_HMAC_MD4

HA_HMAC_MD4

MD5 familyHA_HMAC_MD5_128
Versions 24 and later
MURMUR family
New in version 24
MURMUR family
MURMUR family
  • Versions 24 and later
    HA_MURMUR_1: Murmur algorithm version 1: 32-bit hash result
    New in version 24
    HA_MURMUR_1: Murmur algorithm version 1: 32-bit hash result
    HA_MURMUR_1: Murmur algorithm version 1: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_2: Murmur algorithm version 2: 32-bit hash result
    New in version 24
    HA_MURMUR_2: Murmur algorithm version 2: 32-bit hash result
    HA_MURMUR_2: Murmur algorithm version 2: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processors
    New in version 24
    HA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processors
    HA_MURMUR_2_64A: Murmur algorithm version 2: 64-bit hash result optimized for 64-bit processors
  • Versions 24 and later
    HA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processors
    New in version 24
    HA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processors
    HA_MURMUR_2_64B: Murmur algorithm version 2: 64-bit hash result optimized for 32-bit processors
  • Versions 24 and later
    HA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash result
    New in version 24
    HA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash result
    HA_MURMUR_2_A: Incremental Murmur algorithm version 2: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash result
    New in version 24
    HA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash result
    HA_MURMUR_2_BIG_ENDIAN: Murmur algorithm version 2 for big-endian machine: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash result
    New in version 24
    HA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash result
    HA_MURMUR_2_ALIGNE: Murmur algorithm version 2 for aligned machine: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash result
    New in version 24
    HA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash result
    HA_MURMUR_3_32: Murmur algorithm version 3: 32-bit hash result
  • Versions 24 and later
    HA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processors
    New in version 24
    HA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processors
    HA_MURMUR_3_128_X86: Murmur algorithm version 3: 128-bit hash result optimized for 32-bit processors
  • Versions 24 and later
    HA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors
    New in version 24
    HA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors
    HA_MURMUR_3_128_X64: Murmur algorithm version 3: 128-bit hash result optimized for 64-bit processors
RIPEMD family
  • HA_HMAC_RIPEMD_128
  • HA_HMAC_RIPEMD_160
SHA family
  • HA_HMAC_SHA_160
  • HA_HMAC_SHA_256
  • Versions 25 and later
    HA_HMAC_SHA_256_DOUBLE
    New in version 25
    HA_HMAC_SHA_256_DOUBLE
    HA_HMAC_SHA_256_DOUBLE
  • HA_HMAC_SHA_384
  • HA_HMAC_SHA_512
Versions 23 and later
SHA-3 family
New in version 23
SHA-3 family
SHA-3 family
  • Versions 23 and later
    HA_HMAC_SHA3_224
    New in version 23
    HA_HMAC_SHA3_224
    HA_HMAC_SHA3_224
  • Versions 23 and later
    HA_HMAC_SHA3_256
    New in version 23
    HA_HMAC_SHA3_256
    HA_HMAC_SHA3_256
  • Versions 23 and later
    HA_HMAC_SHA3_384
    New in version 23
    HA_HMAC_SHA3_384
    HA_HMAC_SHA3_384
  • Versions 23 and later
    HA_HMAC_SHA3_512
    New in version 23
    HA_HMAC_SHA3_512
    HA_HMAC_SHA3_512
TIGER family
  • HA_HMAC_TIGER_128
  • HA_HMAC_TIGER_160
  • HA_HMAC_TIGER_192
WHIRLPOOL familyHA_HMAC_WHIRLPOOL
  • 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).
    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
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.
Versions 27 and later
Windows

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.
Caution: this result may contain non-displayable characters. 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
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: 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).
<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 algorithm. 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).
New in version 27
Windows

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.
Caution: this result may contain non-displayable characters. 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
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: 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).
<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 algorithm. 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).
Windows

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.
Caution: this result may contain non-displayable characters. 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
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: 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).
<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 algorithm. 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: The Hash functions operate on the bytes found in the character strings. For the same type of algorithm, the result will differ in UNICODE and in ANSI.
  • Multi-platform development: To use Hash of strings between several platforms (a hash generated in iOS and checked in Android or Windows for example), no Unicode string must be used. 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).
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: wd270com.dll
Minimum version required
  • Version 11
This page is also available for…
Comments
Click [Add] to post a comment