admin管理员组文章数量:1319463
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
3 Answers
Reset to default 4I 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
本文标签: OpenSSL decryption in JavaScriptStack Overflow
版权声明:本文标题:OpenSSL decryption in JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742061636a2418616.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论