HMAC

Description

Calculates the HMAC value of a blob.

Applies to

CrypterObject object

Syntax

crypter.HMAC ( algorithm, variable, key)

Argument

Description

crypter

The name of the CrypterObject object.

algorithm

A value of the HMACAlgorithm enumerated type that specifies the type of HMAC algorithm.

Values are:

  • HMACMD5! – HMAC-MD5

  • HMACSHA1! – HMAC-SHA1

  • HMACSHA224! – HMAC-SHA224

  • HMACSHA256! – HMAC-SHA256

  • HMACSHA384! – HMAC-SHA384

  • HMACSHA512! – HMAC-SHA512

variable

A blob whose value is the data you want to process with HMAC.

When using the system blob function to convert a string to a blob, it is recommended to specify its encoding argument to be EncodingANSI! (for English characters only) or EncodingUTF8!, otherwise, the default EncodingUTF16LE! will be used.

key

A blob specifying the secret key.


Return value

Blob. Returns the result of the HMAC if it succeeds. If any argument's value is null, the method returns null. If an error occurs, throw the exception.

Examples

This statement encrypts the data using HMACMD5.

Blob lblb_data
Blob lblb_key
Blob lblb_hmac
String ls_data

lblb_data = Blob("Test HMAC", EncodingANSI!)
lblb_key = Blob("Test HMAC Key", EncodingANSI!)

CrypterObject lnv_CrypterObject
lnv_CrypterObject = Create CrypterObject

// Encrypt with HMAC
lblb_hmac= lnv_CrypterObject.HMAC(HMACMD5!, lblb_data, lblb_key)

Coderobject lnv_code
Lnv_code = create coderobject
//Encode the HMAC blob data to be hex data and output as a string
Ls_data = lnv_code.hexencode(lblb_hmac)

See also

SymmetricEncrypt

SymmetricDecrypt

SymmetricGenerateKey

AsymmetricEncrypt

AsymmetricDecrypt

AsymmetricSign

AsymmetricVerifySign

AsymmetricGenerateKey

MD5

SHA