I have a database and an API in NodeJS, I create users with web app, and each user can create/update/delete data.

To secure this a bit, I need to encrypt data of users. So what I want is creating a pair of SHA256 public private keys each time a user is created.

Actually what I do is storing thoses keys in database, by encrypting them with global SHA256 pair of key.

So, in a nutshell, I have a global pair of key to encrypt each specific pair of keys for each user.

The fact is that seems to be not really secure because finally each user have his own encryption/decryption method stored in the database.

For example I can have 2 tables :

```
User table :

id_user | firstname | lastname | encrypted_data
-----------------------------------------------
1       | John      | Doe      | QMwmuCMmI..
2       | Jane      | Doe      | QMwmuCMmI..
... 

Keys table :

id_user | public    | private
------------------------------
1       | MIICIjA.. | MIIJrT..    
2       | MIICIjA.. | MIIJrT.. 
...   

```

So the link from `John Doe` to his public and private keys in simple.

A problem is that I can't ask for user to create a pair of private/public key and send me only public, because all need to be automatic, user don't have to do anything.

Another problem is that the application should be usable on any device, so the private key can't be stored in client side.