Trying to convert PHP hash_hmac with multiple XOR components to coldfusion

Viewed 98

I have been given the unenviable task of converting an old set of PHP pages to ColdFusion. My PHP knowledge is not that great, and I'm having a hard time figuring out how to replicate the following line into ColdFusion:

$fingerprint = hash_hmac("md5", $loginID . "^" . $sequence . "^" . $timeStamp . "^" . $amount . "^", $transactionKey);

The values being passed for each variable are a mix of numbers, letters and decimals.

Any help would be greatly appreciated.

1 Answers

ColdFusion alternative for PHP hash_hmac is hmac() with HMACMD5 as algorithm equivalent to md5 in PHP. Also you might want to do a lcase() call to make the result lower case as CF gives an all capitalized result.

<cfscript>
    message = loginID & "^" & sequence & "^" & timeStamp & "^" & amount & "^";
    fingerprint=lcase(hmac(message, transactionKey, "HMACMD5"));
</cfscript>

DEMO

Related