
Jsencrypt provides a simple wrapper around the fantastic work done by tom wu for rsa encryption in javascript (ie: the jsbn javascript library). jsencrypt works hand-in-hand with openssl.
with jsencrypt, you can generate private and public keypairs, then use them to encrypt and decrypt.