Doing the thing itself HMAC-SHA1. It’s best to say that I found this old function. Worked great on what I'm doing so far. I forgot where I found it, although I can’t find the author.
For your base 64 ... run this function on your encryption, and then just type cfset newString = toBase64 (oldString) on what is returned.
<cffunction name="hmacEncrypt" returntype="binary" access="public" output="false"> <cfargument name="signKey" type="string" required="true" /> <cfargument name="signMessage" type="string" required="true" /> <cfargument name="algorithm" type="string" default="HmacSHA1" /> <cfargument name="charset" type="string" default="UTF-8" /> <cfset var msgBytes = charsetDecode(arguments.signMessage, arguments.charset) /> <cfset var keyBytes = charsetDecode(arguments.signKey, arguments.charset) /> <cfset var keySpec = createObject("java","javax.crypto.spec.SecretKeySpec") /> <cfset var mac = createObject("java","javax.crypto.Mac") /> <cfset key = keySpec.init(keyBytes, arguments.algorithm) /> <cfset mac = mac.getInstance(arguments.algorithm) /> <cfset mac.init(key) /> <cfset mac.update(msgBytes) /> <cfreturn mac.doFinal() /> </cffunction>
Steve K.
source share