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!
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.
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?
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>
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.
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.
Copy link to clipboard
Copied
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!