Variable CFUSION_ENCRYPT is undefined

Viewed 233

0 experience with ColdFusion over here.

Got this project dropped off at my desk which was written by somebody 4 years ago, the person doesn't work with my company any more.

Got the logs from the live hosted website, and the error seems to exist on this line.

Line 196:

<p><a href="https://#$.siteConfig().getdomain()##$.createHREF(filename='accounts/verify-email')#?stub=#cfusion_encrypt(uu.username, application.encKey)#">Click here</a> to activate your account</p>

enter image description here

I believe it might have something to do with the fact that the URL exists in quotes and the parameters are not correctly being passed? But I am not certain by any means.

I do not have the code base to test it or debug it, just the live deployed website.

Happy to get any suggestions on how to proceed with this. Thanks!

2 Answers

If your CFML code is hosted on both new and pre-CF11 ColdFusion servers, you may need to use a user-defined function (UDF) to fill the gap. We used the following code while slowly testing & migrating older applications from CF7 to 2016. (Just add these functions to your codebase and rename existing "CFusion_" tags to "Fusion_".)

Published 10/20/2005 by Barney Boisvert: http://www.barneyb.com/barneyblog/2005/10/28/cfusion_encryptcfusion_decrypt-udfs/

<cffunction name="fusion_encrypt" output="false" returntype="string">
    <cfargument name="string" type="string" required="true" />
    <cfargument name="key" type="string" required="true" />
    <cfset var i = "" />
    <cfset var result = "" />
    <cfset key = repeatString(key, ceiling(len(string) / len(key))) />
    <cfloop from="1" to="#len(string)#" index="i">
        <cfset result = result & rJustify(formatBaseN(binaryXOR(asc(mid(string, i, 1)), asc(mid(key, i, 1))), 16), 2) />
    </cfloop>
    <cfreturn ucase(replace(result, " ", "0", "all")) />
</cffunction>
<cffunction name="fusion_decrypt" output="false" returntype="string">
    <cfargument name="string" type="string" required="true" />
    <cfargument name="key" type="string" required="true" />
    <cfset var i = "" />
    <cfset var result = "" />
    <cfset key = repeatString(key, ceiling(len(string) / 2 / len(key))) />
    <cfloop from="2" to="#len(string)#" index="i" step="2">
        <cfset result = result & chr(binaryXOR(inputBaseN(mid(string, i - 1, 2), 16), asc(mid(key, i / 2, 1)))) />
    </cfloop>
    <cfreturn result />
</cffunction>
<cffunction name="binaryXOR" output="false" returntype="numeric">
    <cfargument name="n1" type="numeric" required="true" />
    <cfargument name="n2" type="numeric" required="true" />
    <cfset n1 = formatBaseN(n1, 2) />
    <cfset n2 = formatBaseN(n2, 2) />
    <cfreturn inputBaseN(replace(n1 + n2, 2, 0, "all"), 2) />
</cffunction>

<h2>cfusion_encrypt Test</h2>
<cfset key = "test" />
<cfoutput>
<table>
<cfloop list="barney,is,damn cool!" index="i">
    <tr>
        <td>#i#</td>
        <td>#cfusion_encrypt(i, key)#</td>
        <td>#fusion_encrypt(i, key)#</td>
        <td>#cfusion_decrypt(cfusion_encrypt(i, key), key)#</td>
        <td>#fusion_decrypt(fusion_encrypt(i, key), key)#</td>
    </tr>
</cfloop>
</table>
</cfoutput>

Sounds like you're using now a version of ColdFusion server that does not have the built in cfusion_encrypt() function.

Try this, change

cfusion_encrypt(uu.username, application.encKey)

to

encrypt(uu.username, application.encKey,'CFMX_COMPAT','HEX')


I hope it helps.

Related