I have a form in a .cfm page that uses jquery to validate the form and pass the values on to a ColdFusion cfc via .ajax. That all works. The following is my component code stripped down to show just the pertinent issue.
<cfcomponent displayName="2014 Registration">
<cfset this.encryptionKey = generateSecretKey('AES') />
<cffunction name="confregistration" output="false" access="remote" returnType="string">
<cfargument name="cc" required="true" type="string"/>
<cfargument name="cvv" required="true" type="string"/>
<cfquery datasource="#application.datasource#">
INSERT INTO table_name(cc,cvv)
values(<cfqueryparam cfsqltype="cf_sql_varchar" value="#encrypt(arguments.cc, THIS.encryptionKey)#"/>,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#encrypt(arguments.cvv, this.encryptionKey)#"/>)
</cfquery>
<cfset message = 'Thank you ' & #encrypt(arguments.cc, THIS.encryptionKey)# />
<cfreturn #message# />
</cffunction>
</cfcomponent>
This makes the insert fail completely. In testing if I remove the encryption line the query does it's job and posts to the db. If I also remove the query but return a message containing just: encrypt(arguments.cc, THIS.encryptionKey) I can see the encrypted string.
I'm new to coldfusion but have been using it for several months. I've found some quirks with variables and using the #'s around variables. They are required in some cases but not in others? My form works and the component function passes the arguments.cc value if it is not encrypted. So I'm close but there seems to be some weirdness going on. Any hints as to what might cause the cfparam with the encrypted value to fail?