Question

Errors with encrypt/decrypt after CF7 to CF8 upgrade

Asked by: cafoster

One of our ColdFusion servers was upgraded from 7 to 8 over the weekend, and now we're getting the following error when loading pages that decrypt social security numbers:

"An error occurred while trying to encrypt or decrypt your input string: The input and output encodings are not same."

It's reading the same file with the same key as before ... any idea what could be causing this?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-31 at 12:38:14ID24695904
Topics

ColdFusion Application Server

,

Encryption for Network Security

,

Cold Fusion Markup Language

Participating Experts
3
Points
500
Comments
22

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Encrypt & Decrypt Functions
    Can anyone provide me with a simple encrypt and decrypt function that encrypt/decrypt a password
  2. Encryption and Decryption
    I developed one application in VB backend as a SQL server. In that iam getting data from database. I want to encrypt and decrypt that data. Can you Help me?
  3. encryption / decryption
    Hello all. Didn't know where to post this as it involves both Java and Delphi, so if it is in the wrong area, sorry, and can someone move it to the correct one. Anyhow: I am looking for a way to encrypt a String in Java, and decrypt it in delphi (and visa versa). I can en...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: srikanthmadishettiPosted on 2009-08-31 at 12:51:45ID: 25225805

check whether the key  you use is not a keyword in cf8

 

by: cafosterPosted on 2009-08-31 at 13:17:41ID: 25226063

It's definitely not a keyword, and I'm using straightforward encrypt(ssn,key) and decrypt(ssn,key).

Here's another oddity ... in a test table, I encrypted some of the social security numbers that I had on file, using the exact same encryption key in the exact same file, and the numbers decrypted just fine. I used SQL Server Comparison Tool to compare the encrypted SSNs in my original and test tables, and even though the comparison tool flagged the field content as different, the content looks to be identical. I re-entered data in another field to see if the comparison tool would flag it as different just because the content had been overwritten, but the tool read the data as identical. ???? I'm at a loss.

 

by: _agx_Posted on 2009-08-31 at 13:21:54ID: 25226104

> the content looks to be identical

Don't trust your eyes.  Check the length of both strings and compare the ascii values, character by character. They might differ by some whitespace char's you can't see


<cfoutput>
len = #len(someValue)#<br>
<cfloop from="1" to="#len(someValue)#" index="x">
    <cfset c = mid(someValue, x, 1)>
     pos [#x#] = char #c# asii #asc(c)#<br>
</cfloop>
</cfoutput>

 

by: cafosterPosted on 2009-08-31 at 14:49:16ID: 25226851

You are so right! I thought I would see extra spaces, etc. when I copied the contents to Word and chose to display hidden formatting symbols, but the differences didn't show there. By looping through each character and displaying the ascii value, I could see that the original encrypted value contained an extra space and a line feed that didn't display in Word. Some spot-checking showed that this is likely the case throughout.

I was ready to accept this as the solution, but I'm still left with lots of values encrypted under ColdFusion 7 which will not decrypt with ColdFusion 8 using the identical key. Any ideas there, given the standardized difference between the two encryptions? I tried simply trimming the original encrypted value before decrypting, hoping the extra space and line feed would be ignored, but that didn't work. Thanks for any help!

 

by: _agx_Posted on 2009-08-31 at 15:10:06ID: 25226983

I _know_ I have heard of this issue before, but for the life of me I cannot remember the resolution.  Can you provide an example of the encrypt/decrypt that worked before but does not work now.  Obviously xxx out the confidential parts.

 

by: cafosterPosted on 2009-08-31 at 15:14:01ID: 25227012

How much would you need to see in order for it to be useful? I'm understandably hesitant to post too much.

 

by: _agx_Posted on 2009-08-31 at 15:46:38ID: 25227208

Well never post anything if you are not comfortable with it.  Plus I definitely do NOT need or want to see anything confidential posted here!  I was just looking for the basic shell code that does the encrypt/decrypt.  Once you plug in fake values like "myStringToEncrypt" and "myKey", the code is pretty much the same in any CF application .. and is no more than you see in livedocs


ie <cfset result = encrypt("myStringToEncrypt", "myKey", "AES", "Base64")>  
The actual settings:   AES, Base64, etc... are what is important to me.


I guess the reason I asked to see the code is because of the problem with whitespace and you mentioned something about a file? I was expecting a read from a db.  So it made me wonder if the code could possibly be trimming off extra white-space causing the problem.

But I am going to look around goole in the meantime and see if I cannot jog my memory about this issue.  

 

by: cafosterPosted on 2009-08-31 at 16:05:30ID: 25227319

Gotcha ... for better or worse, I've used the default settings. I trimmed all strings before encrypting them. In my Google searching I came across references to "padding" which initially sounded promising, but I wouldn't think it would relate to my situation since I've used the default settings.

I'm reviewing my code again to see if I'm overlooking something ... since the only change was the upgrade to CF8 (no change to code or data), I can only guess that CF8 requires stricter adherence to something while CF7 was more forgiving.

 

by: _agx_Posted on 2009-08-31 at 16:30:49ID: 25227443

> but I wouldn't think it would relate to my situation since I've used the default settings

Correct

Just for grins, did you try adding the encoding argument. If you are not using it already.
http://blog.cutterscrossing.com/index.cfm/2008/3/11/ColdFusion-8-Gotcha-The-Decrypt-Function

 

by: cafosterPosted on 2009-08-31 at 17:05:26ID: 25227556

I SO thought that was going to work, but alas ... after adding the algorithm and encoding arguments, I no longer received an error message. However, the decrypted value was nothing, blank, empty.

It would seem that adding arguments is heading down the right path, but the arguments that worked for Cutter ...

Decrypt(stringToDecrypt,.key,'CFMX_COMPAT','Hex') />

... didn't work for me :-(

 

by: _agx_Posted on 2009-08-31 at 17:15:30ID: 25227592

Try "UU" instead of "Hex".  I think that was the default for MX7

 

by: cafosterPosted on 2009-08-31 at 17:20:55ID: 25227609

Sadly, replacing "Hex" with "UU" led to the original error.

"An error occurred while trying to encrypt or decrypt your input string: The input and output encodings are not same."

 

by: _agx_Posted on 2009-08-31 at 18:37:13ID: 25227948

You may as well try base64 for grins.  But your original mx7 code just uses the 3 settings: string, key, algorithm?

It is weird, because I get the same results from MX7 and CF8 for

<cfset encryptedString = encrypt("test", "myKey", "CFMX_COMPAT")>

MX 7,0,2,142559
CF 8,0,1,195765

Are you running the latest updates?  <cfdump var="#server#">

 

by: cafosterPosted on 2009-08-31 at 19:05:07ID: 25228073

No better luck with base64, I'm afraid. I double-checked and we are running the latest CF8 update (8,0,1,195765). My original MX7 code only used the two required settings: string and key. I allowed algorithm to default to CFMX_COMPAT (at least that's what the documentation says is the default).

 

by: azadisaryevPosted on 2009-08-31 at 22:19:24ID: 25228698

apparently, if your encrypted string contains characters like space, <, >, + or quotes, CF8 will not be able to decrypt it using CFMX_COMPAT algorythm...

i do not know if that's a bug in CF's implementation of java cryptography (and which CF version is buggy, if it is), or a flaw/differenced in JCE versions shipped with CF7 and CF8, but that's the fact.

i have found several questions regarding this, but no solutions... so the best thing you can do, i guess, is to install CFMX7 (if you do not have it installed), decrypt the strings, and then re-encrypt them using a different algorithm. you should then be able to decrypt them in CF8 using the new algorithm.

Azadi

 

by: azadisaryevPosted on 2009-09-01 at 01:44:53ID: 25229540

would you know that!
adobe has just (1 Sep 2009) released CF 8.0.1 Cumulative Hotfix 3.
and one of the issues it solves (among over 20 others) is bug 75676: "Fix for error 'The input and output encodings are not same' thrown when decrypting an encrypted string using CFMX_COMPAT."

get the hotfix at http://kb2.adobe.com/cps/511/cpsid_51180.html
install it on your server (installation instructions on the linked page) and see if it helps solve the issue.

Azadi

 

by: _agx_Posted on 2009-09-01 at 09:12:50ID: 25233071

Excellent find Azadi!

 

by: cafosterPosted on 2009-09-01 at 12:43:22ID: 31622707

Thank you so much, both _agx_ and azadi, for putting in the time to help me troubleshoot this. I've applied Adobe's hot fix (how timely was that!) to my local CF server, and the application is now decrypting with ease. We'll be applying the hot fix to the production server later this evening. Thank you, thank you, thank you!!

 

by: _agx_Posted on 2009-09-01 at 13:44:58ID: 25235823

cafoster, given the amazing timing you have, you should play the lottery today or something ;-)

 

by: _agx_Posted on 2009-09-01 at 13:48:17ID: 25235862

Also, when you get time switch over to a better algorithm than "CFMX_COMPAT".  Even the documentation hints that it's a bit lame (read easily broken).   So it shouldn't be used for anything important ;-)

 

by: cafosterPosted on 2009-09-01 at 13:51:56ID: 25235904

Talk about timing, someone from our work Lotto group just now stopped at my desk to see I'd paid up for the month (I had).

You're right, _agx_, I need to ditch CFMX_COMPAT for something more secure. I didn't find a solution to my problem yesterday, but in my research I came across enough "CFMX_COMPAT is lame" references to realize I need to change it up. Thanks!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...