Crypto.HMAC

From Xojo Documentation

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

Sample Code

This example creates a hash using HMAC and SHA512:

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