An example on how to use javascript (jsbn) to encrypt data and decrypt it in PHP using phpseclib.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
javascript
phpseclib
README.md
generate.php
index.php

README.md

phpseclib-jsbn-rsa

An example on how to use the jsbn javascript library to encrypt data using RSA and decrypt it in PHP using phpseclib.

  • To generate a new key pair load 'generate.php'. Next copy/paste the private key that is displayed into 'index.php' (you can't miss what needs to be replaced). This way you can just place the project somewhere on a web server supporting PHP and use it.

  • This example just shows you how to do the encryption and decryption using these libraries. Important here is that jsbn expects the public key to be in hex, rather than the OpenSSL type notation generated by phpseclib.

Take a look at rsa-javascript-php if you need a more complete library that also supports different PHP encrytion methods. Although you will probably need to apply the above remark (jsbn requiring a hex public key) to get it to work.

Finally this project used the JQuery and Twitter Bootstrap to do the heavy lifting and make the example page look reasonably good.