User 1 sends two fields:
- plain_text
- password
these fields are passed to encrypt function
encrypted = encrypt(plain_text, password)
the encrypted value is stored in the database
Now User 2 wants to see this plain_text field, he sends one field to the server to request it:
- password
Now the server wants to check to see if the password sent by User 1 is the same as the password sent by User 2 but at the same time he did not store the password sent by User 1, how can the server check that the password is correct before sending the decrypted text.
The motive is that the server is not wanted to:
- send wrong decrypted text
- store the
plain_textin the database - store the correct
passwordin the database
What is the simplest way to achieve this?