Right idea. However, if you're using MySQL, the docs recommend against that: http://dev.mysql.com/doc/refman/5.1/en/encryption-functions....
Use a different hashing function, probably bcrypt. (Note to self: go back and check some of my old code that did/does exactly what you describe...doh!)