Search code examples
mysqlencryptionmysql-logic

MYSQL: using des decrypt function with lower


I have encrypted user data in my database using des_encrypt, now when i specify a particular statement as below:

SELECT LOWER( DES_DECRYPT( forename, 'ENCRYPT STRING' ) )
FROM Users

All the results are NOT returned in lowercase, anybody know what i am doing wrong? or perhaps how another way to do it?

p.s ENCRYPT STRING is a random character string, not the actual word. Thanks, Matt


Solution

  • You may try this:

    SELECT LOWER ( CONVERT ( DES_DECRYPT ( forename, 'ENCRYPT STRING' ) USING utf8 ) )
    AS forename_decrypted FROM Users
    

    The Lower-function can only convert strings, I don't know exactly if DES_DECRYPT returns a string or simply binary data..