Whatever message this page gives is out now! Go check it out!

HMac

Last update:
May 18, 2026

Description

Creates Hash-based Message Authentication Code for the given string based on the algorithm and encoding. Hash-based Message Authentication Code (HMAC) is used to verify the data integrity and authenticity of a message transmitted. It involves a cryptographic hash function in combination with a secret key. The cryptographic hash function can be Message Digest 5 (MD5), Secure Hash Algorithm (SHA), and so on.

Returns

An encoded string

Category

History

ColdFusion 10: Added this function.

Syntax

HMac(message, key [,algorithm] [,encoding])

See also

History

ColdFusion 10: Added this function.

Parameters

Parameter
Required\Optional
Description
message
Required
The message to transmit. The message can be a String or a byte array.
key
Required
The secret key to create HMAC. The key can be a String or a byte array.
algorithm
Optional
The hash algorithm to use. The following is a list of HMAC algorithms:
  • HMACMD5
  • HMACRIPEMD160
  • HMACSHA1
  • HMACSHA224
  • HMACSHA256
  • HMACSHA384
  • HMACSHA512
encoding
Optional
The character encoding to use.

Usage

Use this function to create Hash-based Message Authentication Code for the given string based on the algorithm and encoding.

Example

<cfscript>
    x=hmac("Hi There","key1","HMACRIPEMD160")
    writeOutput(x) // 4E1A31DD8A26BDB9344D391D44DDCA9B28F10739
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page