• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Encrypt Decrypt Problem

Explorer ,
Feb 22, 2016 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

540

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
community guidelines
Guide ,
Feb 22, 2016 Feb 22, 2016

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Explorer ,
Feb 22, 2016 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)

Votes

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
community guidelines
Guide ,
Feb 22, 2016 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.

Votes

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
community guidelines
Advocate ,
Feb 23, 2016 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.

Votes

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
community guidelines
Explorer ,
Feb 24, 2016 Feb 24, 2016

Copy link to clipboard

Copied

LATEST

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.

Votes

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
community guidelines
Resources
Documentation