Copy link to clipboard
Copied
I am suddenly getting an error in a script that has been working for years where I encrypt an html file so that is can't be accessed via a browser and then decrypt it for later reference
The encrypting scheme is very basic:
<cfset archivefile="<HTML><BODY>" & paynowbutton & invoiceheader & invoicebody & "</body></html>">
<cfset tempinvoice=encrypt(archivefile,session.key)><!---session.key is a 4 digit PIN number--->
<cffile action = "write" file = "#application.LocalRoot#\invoices\#brokerid#_invoice.html" output = "#tempinvoice#">
THEN TO UNENCRYPT
<cffile action="read" file = "#application.LocalRoot#\invoices\#form.brokerid2#_invoice.html" variable="invoice">
<cfset invoice=decrypt(invoice,session.key)>
THEN THE ERROR WHICH HAS BEEN INCREASING IN FREQUENCY
An error occurred while trying to encrypt or decrypt your input string: The input and output encodings are not same
ANY IDEAS??
Copy link to clipboard
Copied
Did you upgrade to a newer ColdFusion version after some of the encrypted files were generated?
Copy link to clipboard
Copied
Negative. In fact the code above fails immediately. As soon as is encrypted and saved as a file I can not decrypt it. I can however decrypt the encrypted content while it is still a variable (before storing as a file)
Copy link to clipboard
Copied
"Encodings" might be the important bit. I'm not well-versed in the subject, but it might be reading and writing using different character sets. Try adding the "charset" attribute to both CFFILE calls.
Copy link to clipboard
Copied
My vote for the most likely cause is what Carl said: encoding.
A second more remote guess might be malware modifying your .html file with spam links, corrupting your encrypted data. I ran into this a couple years back with an account I had on a shared hosting provider. They had malware adding spam to html files.
Copy link to clipboard
Copied
I appreciate the suggestions, and adding charset on both ends of the transaction is a sound idea.
What I ended up doing though is recreating the documents as PDF wherever the decrypting failed, and will use this process going forward.