HMAC SHA1 in Coldfusion?

Posted on 2006-03-22
Last Modified: 2013-12-20
Hello there,

I'm wondering if there is a simple way to implement HMAC SHA1 in coldfusion.

The PHP version looks like this:

//Calculate HMAC-SHA1 according to RFC2104
function hmacsha1($key,$data) {
   if (strlen($key)>$blocksize)
       $key=pack('H*', $hashfunc($key));
   $hmac = pack(
   return bin2hex($hmac);

I think most of it is fairly straightforward, however I don't know if there is a good way to work with hex data in coldfusion. Any help would be appreciated.

Question by:umbrae
    LVL 16

    Expert Comment

    Depends on the CF Version, In version 7, the HASH Function supports SHA1.  There is also a custom tag for prior version. I'll look it up and get back in a minute.
    LVL 16

    Accepted Solution

    LVL 5

    Author Comment

    HMAC sha1 isn't just sha1:
    LVL 5

    Author Comment

    Ah! it appears theres a CF_HMAC tag. Thats exactly what I was looking for.

    LVL 16

    Expert Comment

    I understand now. The SHA-1 part is only a piece. The EE link that I showed though was trying to do the HMAC SHA-1 though I believe.
    I think this link is the macromedia custom tag to do the HMAC.

    The EE link showed how to implement it.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    excpetion with multiple catch 11 97
    Citrix netscaler connection to Web Interface 9 88
    Web Site Hosting 10 57
    CFFILE upload help 98 88
    Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
    This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
    The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
    The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now