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

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

Participant ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

I keep getting this error and I am not sure why:

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

I think it is because the password is being pulled from a database.

Here is my code:

<cfquery datasource="#datasource#" dbname="#dbname#" password="#password#" name="getpass">

SELECT email,pass,username

FROM members

WHERE email = '#email#'

</cfquery>

<cfoutput>

#decrypt("getpass.pass", "xxxxxxxxxxxxxxxxxxxx==", "AES", "Base64")#

</cfoutput>

Thanks!

Views

2.7K

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

correct answers 1 Correct answer

Advocate , Jan 10, 2019 Jan 10, 2019

BACFL  wrote

#decrypt("getpass.pass", "xxxxxxxxxxxxxxxxxxxx==", "AES", "Base64")#

Oh, I think I see the problem. You're passing the value "getpass.pass" to the function instead of the value of getpass.pass.

Remove the quotes and you should be good to go.

Votes

Translate

Translate
Community Expert ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

BACFL  wrote

I keep getting this error and I am not sure why:

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

I think it is because the password is being pulled from a database.

Why do you think so, when ColdFusion is telling you the input and output encodings are not the same?

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
Participant ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

Because if I encrypt and then decrypt on thBe same page I don't get the error.

<cfoutput>

<cfset encryptedpassword = #encrypt("abcde", "xxxxxxxxxxxxxxxxxxxx==", "AES", "Base64")#

<p>

#encryptedpassword#

RESULT: NFVVQObl4Bmj0K+38T6ffQ==

<cfset password = #decrypt("NFVVQObl4Bmj0K+38T6ffQ==", "xxxxxxxxxxxxxxxxxxxx==", "AES", "Base64")#

#passsword#

RESULT: abcde

</cfoutput>

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 ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

What is the value of the pass field in the database?

If it is not the same as the encryptedpassword variable then you are not storing the value in the database correctly.

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 ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

BACFL  wrote

#decrypt("getpass.pass", "xxxxxxxxxxxxxxxxxxxx==", "AES", "Base64")#

Oh, I think I see the problem. You're passing the value "getpass.pass" to the function instead of the value of getpass.pass.

Remove the quotes and you should be good to go.

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
Participant ,
Jan 14, 2019 Jan 14, 2019

Copy link to clipboard

Copied

LATEST

Eddielotter, thanks you were correct.  Removing the quotation marks helped.  That was also causing the variable "pass" to be encrypted and stored in the database instead of the actual password.

Thanks again!

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