title: How to securely store a password in a database while still being recoverable
body: <p>For an application that I am working on I want to store passwords that a user enters in a way that provides some security in the event that my database is compromised but still allows an external daemon to have access to the plaintext version of the password. (It will be used for IMAP or POP logins). </p>
  
  <p>What is the best way to store a password in the database so it is recoverable without the user's original password. (Not encrypted with the user's password)</p>
  
  <p>I was thinking maybe public key encryption where the front end would use the public key to encrypt the password for store in the database and then the accessing daemon would decrypt the password with the private key.</p>
  
  <p>EDIT:
  I need the plaintext passwords so that they can be used to log on to other websevices which may not support something like OAuth</p>