I've got a web service (similar to an online store) where users save their data. I need to encrypt that data, so that only managers and users themselves could read that data.
Every manager and user has his own password stored hashed in the database.
First i've thought to use RSA(public/private keys), but i can't figure out how to gain access to the encrypted data using different passwords of managers and users.
BTW: i can prompt user and manager to enter his password every time they try to access encrypted data (compare with hashed one in database and decrypt secured data).
Please help and excuse me for my poor English. Thanks in advance!
EDIT: the simplest way is to use hardcoded master-password for both encryption/decryption, but i think that is very very insecure.
EDIT2: ok, i think i've got the idea: 1. generate unique key 2. using symmetric encryption encrypt data with unique key from (1) 3. encrypt unique key from (1) with user's password and store it with user's credentials 4. encrypt unique key from (1) with manager's password and store it with manager's credentials
now when manager wants to access data, i prompt him for a password, then decrypt hash from (4), get unique key from (1) and decrypt secure data. decryption from user is the same: (3)->(1)->data
so now problem is to make this available for multiple users->user_data/managers, lol
EDIT3: forgot to mention: users create data once and then managers use it for internal use.