Highlighted

Encrypt Decrypt Problem

Explorer ,
Feb 22, 2016

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??

Views

420

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Encrypt Decrypt Problem

Explorer ,
Feb 22, 2016

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??

Views

421

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 22, 2016 0
Most Valuable Participant ,
Feb 22, 2016

Copy link to clipboard

Copied

Did you upgrade to a newer ColdFusion version after some of the encrypted files were generated?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 22, 2016 0
Explorer ,
Feb 22, 2016

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)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 22, 2016 0
Most Valuable Participant ,
Feb 22, 2016

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 22, 2016 1
Advocate ,
Feb 23, 2016

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 23, 2016 1
mtnhomes LATEST
Explorer ,
Feb 24, 2016

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 24, 2016 0