Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
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

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!

3.2K
Translate
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.

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

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?

Translate
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

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>

Translate
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

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.

Translate
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

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.

Translate
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
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!

Translate
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