Working with OpenID CFC project I found another way to create HMAC:SHA1 string using Java:

<cffunction name="HMAC_SHA1" returntype="binary" access="public" output="false">
	<cfargument name="signKey" type="string" required="true" />
	<cfargument name="signMessage" type="string" required="true" />

	<cfset var jMsg = JavaCast("string",arguments.signMessage).getBytes("iso-8859-1") />
	<cfset var jKey = JavaCast("string",arguments.signKey).getBytes("iso-8859-1") />

	<cfset var key = createObject("java","javax.crypto.spec.SecretKeySpec") />
	<cfset var mac = createObject("java","javax.crypto.Mac") />

	<cfset key = key.init(jKey,"HmacSHA1") />

	<cfset mac = mac.getInstance(key.getAlgorithm()) />
	<cfset mac.init(key) />
	<cfset mac.update(jMsg) />

	<cfreturn mac.doFinal() />


So I am going to include this code to next release of the project.

Dmitry Yakhnov

I am Senior Web Developer with 15+ years of experience dealing with ColdFusion.

Currently living in Melbourne, Australia.

Share this post