CryptoHash belongs to the Cryptography data types.
||Returns the text resulting from the application of the hash function on the text entered.
As Keyed-Hash Message Authentication Code is supported, a key can be optionally passed to the method.
||Allows us to specify the hash algorithm that will be applied when the Compute(String,[key]) method is invoked. The SHA256 is used by default .
CryptoHashAlgorithm is a predefined enumerated domain containing the Hash algorithms supported.
The example below uses the Hash algorithm SHA1.
&CryptoHash.Algorithm = CryptoHashAlgorithm.SHA1 //&CryptoHash is of CryptoHash type.
&resultstringSHA1 = &CryptoHash.Compute(&text)
The following example uses the HMAC SHA512 algorithm.
&CryptoHash.Algorithm = CryptoHashAlgorithm.HMACSHA512 //&CryptoHash is of CryptoHash type.
&resultingstringHMACSHA512 = &CryptoHash.Compute(&text,&key)
- The SHA256 is used by default since GeneXus Evolution v15 U10. The previous versions use SHA1
- When using a Non-Keyed-Hash Message Authentication code in Compute method, if a key is specified the following error is thrown:
3.00 Algorithm does not support Hashing with Key. Please use HMAC instead or remove the Key parameter
- When using sing Keyed-Hash Message Authentication code, the &CryptoHash.Algorithm property should be set to HMACSHA256, HMACSHA1, HMACSHA384, HMACSHA512, or HMACMD5.
In such case, if &CryptoHash.Algorithm is set to any of these values and no key is specified, the following error is thrown:
4.00 Key must be specified.
Another possible error is the following:
5.00 Invalid Key.
||Web(.NET,Java), Smart Devices (iOS)
The availability of the Keyed-Hash Authentication is as of GeneXus 15 Upgrade 3.
For Smart Devices enviroment, is available as of Genexus 15 Upgrade 10.