Skip to main content
Inspiring
Jan 10, 2019 11:01 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
    EddieLotter
    EddieLotterCorrect answer
    Inspiring
    Jan 10, 2019 11:41 PM UTC

    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.

    5 replies

    EddieLotter
    EddieLotterCorrect answer
    Inspiring
    Jan 10, 2019 11:41 PM UTC

    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
    BACFLAuthor
    Inspiring
    Jan 14, 2019 11:30 PM UTC

    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
    BKBK
    Community Expert
    Community Expert
    Jan 10, 2019 11:15 PM UTC

    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
    BACFLAuthor
    Inspiring
    Jan 10, 2019 11:27 PM UTC

    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
    EddieLotter
    Inspiring
    Jan 10, 2019 11:39 PM UTC

    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