Official Content

Note: This is part of GeneXus Cryptography Module.

Keyed-Hashing for Message Authentication

As defined by RFC2104 any hash function can be used with HMAC.

HMAC

Calculate

Calculates an HMAC with the given password and hash algorithm.

Hmac.Calculate(plainText, password, hashAlgorithm)
  • Input plainText: VarChar(256)
  • Input password: VarChar(256) hexadecimal
  • Input hashAlgorithm: HashAlgorithm Domain value
  • Returns: VarChar(256) hexadecimal 
Example:
&plainText="Lorem ipsum dolor sit amet"
&password="64887e525dce27351f5cb5ce85615e52"
&mac=&Hmac.Calculate(&plainText, &password, HashAlgorithm.SHA1)

Validate

Validates an HMAC for the given text with the password and hash algorithm indicated.

Hmac.Validate(plainText, password, mac, hashAlgorithm)
  • Input plainText: VarChar(256)
  • Input password: VarChar(256) hexadecimal
  • Input ma: VarChar(256) hexadecimal
  • Input hashAlgorithm: HashAlgorithm Domain value
  • Returns boolean true if the mac is valid
Example:
&plainText="Lorem ipsum dolor sit amet"
&password="64887e525dce27351f5cb5ce85615e52"
&mac = "50D4AE631960E8D040FBEC617EF442B7AB251221"
&valid=&Hmac.Validate(&plainText, &password, &mac, HashAlgorithm.SHA1)

 




Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant