title: En/decrypt data using password without database admin being able to decrypt it
body: <p>This is a more conceptual question, but I'm trying to have some content be made available only to a specific user at a time. To do so, I thought about using a users password as an encryption key. However, the problem with that is that if I encrypt it using the plaintext password, I won't be able to encrypt anything as I'm obviously storing a hashed version in my database. If I encrypt it using the hashed password, then any database admin will be able to read the content of every user.</p>
  
  <p>So basically, I need some kind of public/private key concept where I can encrypt it with a users public key but only they have access to their private key to decrypt it. Using actual RSA keys will be annoying in terms of usability though, as a user would have to write down their private key somewhere.</p>
  
  <p>Is there a clever way for me to store data in a way that only a specific user can see it, somehow accessible through a password they set without being able to see their data as a server admin?</p>
  
  <p>Example, assuming a website:</p>
  
  <p>Random person chooses a receiver person, writes a message. That message should be stored in encrypted form in the database, using some form of public key.</p>
  
  <p>Receiver person enters their password (Not a huge RSA key, optimally, but a standard passphrase), on the server side this password will be treated as some form of private key in order to deencrypt the data and send it back to the client.</p>
  
  <p>So basically, I want to treat a simple passphrase as a private key, and generate a corresponding public key for it.</p>