利用jsencrypt 作非對稱加密

一、生成 private keybash

openssl genrsa -out rsa_1024_priv.pem 1024

二、生成public key加密

openssl rsa -pubout -in rsa_1024_priv.pem -out rsa_1024_pub.pem

三、根據public key對數據加密blog

let encrypt = new JSEncrypt();
encrypt.setPublicKey(__YOU_CREATE_PUBLIC_KEY__);
let encrypted = encrypt.encrypt(__YOU_ENCRYPT_DATA__);
             

 四、根據private key對加密數據解密ssl

let decrypt = new JSEncrypt();
decrypt.setPrivateKey(__YOU_CREATE_PRIVATE_KEY___);
let uncrypted = decrypt.decrypt(__YOU_ENCRYPTED_DATA__);
相關文章
相關標籤/搜索