Have a look at the [man]mcrypt[/man] functions (assuming they're installed); these offer two-way encryption.
A thought occurs: for security, these things expect a key string to be used. Many sites that offer password-recovery include a challenge-response test. When the user sets up a password they provide a question and its answer (both get stored; the answer could be MD5ed). If they later want to recover the password, they're asked the question and have to provide the answer to get the password.
This is to prevent any wally from asking for the password (another defence is to email the password to the user, but this assumes that you collect email addresses). But it also has a use for password encryption: the answer could be used as the key to decrypt the password.