Crypto.HMAC

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

Crypto.HMAC(key As String, data As MemoryBlock, hashAlgorithm As Crypto.HashAlgorithms) As MemoryBlock

New in 2020r2

Supported for all project types and targets.

Creates the hash-based message authentication code using the data and the supplied key value and the supplied hashAlgorithm.


Method

Crypto.HMAC(key As String, data As MemoryBlock, hashAlgorithm As Crypto.Algorithm) As MemoryBlock

New in 2012r2

Supported for all project types and targets.

Creates the hash-based message authentication code using the data and the supplied key value and the supplied hashAlgorithm.

Notes

The key value is applied to the data before generating the hash.

See HMAC on Wikipedia.

Use the Crypto.HashAlgorithms enumeration with the Hash method to specify the type of hash. It has these values:

  • MD5
  • SHA1
  • SHA2_256
  • SHA2_512
fa-exclamation-circle-32.png
HMAC does not support CRC32, SHA3_256 and SHA3_512 modes. Using them will raise an UnsupportedOperationException.

Sample Code

This example creates a hash using HMAC and SHA512:

Var hash As String
hash = Crypto.HMAC("SaltValue", "YourPasswordSentence", Crypto.HashAlgorithms.SHA512)