House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  SQL

MySQL AES DECRYPT Coldfusion 8 works, Coldfusion 9 returns binary

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Christian St.Germain
05/13/2010 11:28 AM

I have developed an application with CF8 and MySQL 5. Some of the data fields are encrypted using the MySQL AES_ENCRYPT function for INSERT and UPDATE and the AES_DECRYPT function for SELECT. Queries (and dumps) all run fine with either SQL statements alone or with cfc and cfm scripts in CF8.  With CF9 however, the encrypted fields are returned as binary via cfdump even though the SQL statements themselves all run fine using Navicat for MySQL. I can overcome this by recoding he relevant cfm using CharsetEncode(datafield, "utf-8") but this results in an error when used with CF8. Any thoughts or suggestions would be greatly appreciated. I have tried this as well: http://www.compoundtheory.com/?action=displayPost&ID=421

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Leigh _
06/02/2010 04:16 AM

----- Excess quoted text cut - see Original Post for more ----- It sounds a lot like this old MySQL bug. Though the comments say it was fixed eons ago. If not, try casting it to a string in the sql http://bugs.mysql.com/bug.php?id=12872

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Christian St.Germain
06/14/2010 02:58 PM

----- Excess quoted text cut - see Original Post for more ----- Yep that was it.  Thanks so much for sorting that one out for me.  Now the code works in both CF8 and CF9 This works: CAST(AES_DECRYPT('fieldname', 'key') AS CHAR) AS 'alias' The field types in question are varchar.  The default encoding is UTF-8.  There does not seem to be a need to provide an length limit argument in the CHAR function.  i.e. CHAR alone works - not necessary to use CHAR(#). Thanks again.


<< Previous Thread Today's Threads Next Thread >>

Search sql

May 18, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference