1

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.

2
  • Why are you doing this manually instead of letting the browser and web server handle it automatically by using HTTPS? Commented Nov 20, 2012 at 12:02
  • check out stackoverflow.com/a/3977325/861940 Commented Nov 20, 2012 at 12:06

3 Answers 3

4

I found the answer:

I found an encryption algorithm in this page:
https://github.com/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

Sign up to request clarification or add additional context in comments.

Comments

2

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.com/digitalbazaar/forge

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.