Quantcast
Channel: ShortFusion Blog - Encryption
Viewing all articles
Browse latest Browse all 2

ColdFusion HMACMD5 function

0
0

Several months ago, we were integrating our LinkShare affiliate program with our ColdFusion based e-commerce system. During that process, while preparing an MD5 encrypted HMAC message signature for transmitting transaction data to our affiliate tracking account, we encountered a problem with the included encryption algorithms in CF8.

Even though the enterprise version of CF8 includes the hmacmd5 encryption library, we couldn't get it to work, so we reverted to a Java-based implementation wrapped in a function inside one of our Utils CFC's.

Here's how we did it

HMAC MD5 Encryption Function

Place this function inside a Utilities CFC or similar, or use as an UDF

key = CreateObject("java","javax.crypto.spec.SecretKeySpec"); key.init(myKeyByteArray,"HmacMD5"); hmac = CreateObject("java","javax.crypto.Mac"); hmac = hmac.getInstance("HmacMd5"); hmac.init(key); hmac.update(myMessageByteArray); hmac = hmac.doFinal();

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images