openssl生成rsa密钥对
私钥生成 openssl genrsa -out rsa_1024_priv.pem 1024
公钥生成 openssl rsa -pubout -in rsa_1024_priv.pem -out rsa_1024_pub.pem
jQuery使用rsa密钥可以用jsencrypt,github地址:https://github.com/travist/jsencrypt
主要功能代码:
//用公钥加密
var encrypt = new JSEncrypt();
encrypt.setPublicKey(public_key);
var encrypted = encrypt.encrypt(msg);
// 私钥解密 Decrypt with the private key...
var decrypt = new JSEncrypt();
decrypt.setPrivateKey(private_key);
var uncrypted = decrypt.decrypt(encrypted);