Code: https://github.com/ageyev/ageyev.github.io/tree/master/crypto/rsa/index.html
Using JSEncrypt ( https://github.com/travist/jsencrypt)