Avatar of tonelm54
tonelm54
 asked on

AES_ENCRYPT and AES_DECRYPT

Im trying to encrypt a password to be held in a database, however I need to know the password to authenticate against another system so need to be able to decrpyt it again.

So to encrypt the password Im using:-
INSERT INTO `suppliers`.`users` (`username`, `password`) VALUES ('user1', AES_ENCRYPT('mypassword','cryptstring'))

Open in new window


And then to decypt it Im using:-
SELECT `username`,  unhex(AES_DECRYPT(`users`.`password`,'cryptstring')) FROM `suppliers`.`users`

Open in new window


Which should work, however it returns as a decrpted password as '6d7970617373776f7264' which I initally thought was HEX representation of the password but when I try to run it through unhex it just returns null

Any ideas?
MySQL Server

Avatar of undefined
Last Comment
tonelm54

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Chris

Did this resolve your problem?
tonelm54

ASKER
Thank you
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes