Developer Documentation Library > UNICOM Intelligence Function Library > Miscellaneous functions > HashHMAC
 
HashHMAC
Generate an encoded keyed hash value by using the HMAC method. This might be useful to verify the integrity and authenticity of a message or data when communicating with web services from an interview script.
Syntax
HashHMAC(<value>, [<key>], [<algorithm>], [<hex_encoding>]) As String
Parameters
<value>
Type: String
The text to be encoded.
<key>
Type: String
The shared secret key used for generating the HMAC variant of the value.
<algorithm>
Type: String
(Optional.) The hashing algorithm to use: SHA256 or SHA512.
<hex_encoding>
Type: Boolean
(Optional.) True generates a hex-encoded character string. False generates a Base64‑encoded character string. The default value is False.
(return)
Type: String
Returns the encoded hash string.
Example
Dim Result
Result = HashHMAC("/projects/end?rst=2&psid=aYA3xQ6gory1u7hdS5o9AQ**&_k=2000", "28395fc5d93474aa4f53ba2d0a6c07e276074ed", , True)
Debug.Log("SHA256 HMAC Hex encoded: " + Result)

Result = HashHMAC("/projects/end?rst=2&psid=aYA3xQ6gory1u7hdS5o9AQ**&_k=2000", "28395fc5d93474aa4f53ba2d0a6c07e276074ed")
Debug.Log("SHA256 HMAC Base64 encoded: " + Result)

Result = HashHMAC("/projects/end?rst=2&psid=aYA3xQ6gory1u7hdS5o9AQ**&_k=2000", "28395fc5d93474aa4f53ba2d0a6c07e276074ed", "SHA512" , True)
Debug.Log("SHA512 HMAC Hex encoded: " + Result)

Result = HashHMAC("/projects/end?rst=2&psid=aYA3xQ6gory1u7hdS5o9AQ**&_k=2000", "28395fc5d93474aa4f53ba2d0a6c07e276074ed","SHA512")
Debug.Log("SHA512 HMAC Base64 encoded: " + Result)
See also
Hash
Miscellaneous functions