Technology and Programming06 Feb 2008 04:22 pm
Encrypt and Decrypt Strings in mySQL sql Queries
Many times you need a quick encryption solution in a database but do not want the overhead of coding something more complex. mySQL provides you with a simple encryption solution directly in the sql query.
TO ENCRYPT:
INSERT INTO users (user, pass) VALUES (’$username’, AES_ENCRYPT(’$pass’, ’secret encryption key’));
TO DECRYPT:
SELECT user, AES_DECRYPT(pass, ’secret encryption key’) FROM users