title: Two-way encryption: I need to store passwords that can be retrieved
body: <p>I am creating an application that will store passwords, which the user can retrieve and see.  The passwords are for a hardware device, so checking against hashes are out of the question.</p>
  
  <p>What I need to know is:</p>
  
  <ol>
  <li><p>How do I encrypt and decrypt a password in PHP?</p></li>
  <li><p>What is the safest algorithm to encrypt the passwords with?</p></li>
  <li><p>Where do I store the private key?</p></li>
  <li><p>Instead of storing the private key, is it a good idea to require users to enter the private key any time they need a password decrypted? (Users of this application can be trusted)</p></li>
  <li><p>In what ways can the password be stolen and decrypted? What do I need to be aware of?</p></li>
  </ol>