最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

OpenSSL decryption in JavaScript - Stack Overflow

programmeradmin0浏览0评论

I have a PHP webpage, where I use OpenSSL to encrypt a text in PHP (openssl_private_decrypt).

Encripted text:

bhYtdNghwutjxqgHg8AoyebLm5AY+X/4GLNzzb0PVuyiUX2QKwwDBXH4kVQFJIqUUrm6nYGk740wWkSoAMzygA==
Public key: -----BEGIN PUBLIC KEY-----MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMYQWDqtLgDKlQvWzacGeBMQpbicd/uoXAvgLNpFZLM7zuYFDhrYncRsl8LIHK0K3f7e1aFmUVgM4LrKU2WFIw0CAwEAAQ==-----END PUBLIC KEY-----

I don't know how to decrypt it in a browser in JavaScript. I'm looking for some code or library, which I can decode it.

I have a PHP webpage, where I use OpenSSL to encrypt a text in PHP (openssl_private_decrypt).

Encripted text:

bhYtdNghwutjxqgHg8AoyebLm5AY+X/4GLNzzb0PVuyiUX2QKwwDBXH4kVQFJIqUUrm6nYGk740wWkSoAMzygA==
Public key: -----BEGIN PUBLIC KEY-----MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMYQWDqtLgDKlQvWzacGeBMQpbicd/uoXAvgLNpFZLM7zuYFDhrYncRsl8LIHK0K3f7e1aFmUVgM4LrKU2WFIw0CAwEAAQ==-----END PUBLIC KEY-----

I don't know how to decrypt it in a browser in JavaScript. I'm looking for some code or library, which I can decode it.

Share Improve this question edited Oct 16, 2019 at 6:16 4b0 22.3k30 gold badges96 silver badges143 bronze badges asked Nov 20, 2012 at 12:01 HorbertHorbert 3713 gold badges6 silver badges16 bronze badges 2
  • Why are you doing this manually instead of letting the browser and web server handle it automatically by using HTTPS? – Quentin Commented Nov 20, 2012 at 12:02
  • check out stackoverflow./a/3977325/861940 – Bruno Commented Nov 20, 2012 at 12:06
Add a ment  | 

3 Answers 3

Reset to default 4

I found the answer:

I found an encryption algorithm in this page:
https://github./ziyan/javascript-rsa (You need the rsa.js and jsbn.js)
But it only contains the encryption algorithm, and some characters are encrypted bad.

I have written a decryption code into the js, and changed the code that makes an error in the encryption.

And you'll need the following libraries from here!

  • prng4.js
  • rng.js

Finally you should change the following text for this:

var RSA = {
   ...
}

I hope it can help somebody.
Horbert

You may want to try out forge as well -- it does RSA encryption/decryption and more. There are lots of examples on the README:

https://github./digitalbazaar/forge

What you could also use is our NoSSL, it is open-source and free for private/non-mercial use: http://www.nossl There is also an Indiegogo campaign right now: http://www.indiegogo./projects/nossl-security-for-your-website/x/6399437

发布评论

评论列表(0)

  1. 暂无评论