11

How would I be able to decrypt some encrypted data on the client side of a web application?

E.g.

  • The data is stored encrypted on the server.
  • It was encrypted using a public GPG key.
  • The server sends the encrypted to the client.
  • The client needs to decrypt it using their local private key.

Assumably I would be able to pass the private key to the browser and use Javascript to decrypt the data.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
Petah
  • 45,477
  • 28
  • 157
  • 213
  • Host proof hosting https://www.passpack.com/blog/2008/03/host-proof-hosting/ – Petah Sep 07 '14 at 21:14
  • Please see my a little related question: http://stackoverflow.com/questions/30951805/encrypt-on-server-side-and-decrypt-on-client-side – Dr.jacky Jun 27 '15 at 08:38

2 Answers2

14

If you want to stick with JavaScript, then have a look at the LGPL library OpenPGP.js.

Mike R
  • 302
  • 1
  • 5
  • 14
Jens Erat
  • 37,523
  • 16
  • 80
  • 96
3

I know I'm coming a bit late to this, but for future reference, there's always an option of using crypto-browserify via Browserify.

Marko Bonaci
  • 5,622
  • 2
  • 34
  • 55
  • Does it include OpenPGP? – Eugene Mayevski 'Callback Mar 17 '15 at 10:06
  • 1
    No, it doesn't, but there is a library called [openpgp.js](http://openpgpjs.org/) (see [here](https://github.com/openpgpjs/openpgpjs/issues/254) for browserify specifics). It's important to note that, depending on the expected load, it might be beneficial to offload the encryption and decryption to a web worker, to avoid blocking the browser's main UI thread. – Marko Bonaci Mar 17 '15 at 20:06