While the two solutions you have been given are what you asked for, please don't use this approach
It's much more secure to store a hash of the password at the server end, than any symmetrically encrypted alternative
When the password is created, the server stores a hash
When the password is entered for authentication, only the hash is sent to the server for comparison
The Key to a Secure Password[
^]