Skip to main content
Inspiring
January 10, 2019
Answered

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

  • January 10, 2019
  • 2 replies
  • 3541 views

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!

    This topic has been closed for replies.
    Correct answer EddieLotter

    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.

    2 replies

    EddieLotter
    EddieLotterCorrect answer
    Inspiring
    January 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.

    BACFLAuthor
    Inspiring
    January 14, 2019

    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!

    BKBK
    Community Expert
    Community Expert
    January 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?

    BACFLAuthor
    Inspiring
    January 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>

    EddieLotter
    Inspiring
    January 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.