I have this use case:

  1. User1 uploads his file into the database which should be encrypted.
  2. Any other users who request that file, user1 will be notified for approval, on approving other users should be able to view the file but can't download the file.
  3. The file should be encrypted in the database so that it cannot be viewed if the database is hacked.
  • 1
    What is your question? – AndrolGenhald Jan 23 '19 at 14:40
  • 1
    "other users should be able to view the file but can't download the file" - This is contradictory, to view something means downloading it. – AndrolGenhald Jan 23 '19 at 14:41
  • As @AndrolGenhald already mentioned, what you are asking to do is impossible to achieve. To achieve a similar goal, you might want to look into Digital Rights Management (DRM) It sounds like you may be trying to code a product which already exists. – Dan Landberg Jan 23 '19 at 20:25

As pointed out in the comments, you cannot reliably enforce your second point (viewing without downloading). I think what you have in mind is some kind of client-side mitigation. Keep in mind that at best, you are delaying a motivated user. As pointed out in the comments to your question, in order to be displayed the client has to receive a copy of the data sent by the server. Now, there are some pdf viewing libraries that try to obfuscate the source of the data. They are at worse an inconvenience.

Back to the rest of your question, it is impossible to answer without more information. Are keys allowed to be shared? Should they be revokable? Do you want an user to be able to recover their files if they lost their secret key? Do you want to dynamically adjust the set of people allowed to view a certain file? and many more.

Database encryption is a well researched topic. And it is also extremely vast. Please narrow down the problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.