jsencrypt进行rsa加密

安装

npm i jsencrypt --save

引入

import {JSEncrypt} from 'jsencrypt';

加密

// 新建JSEncrypt对象
const encryptor = new JSEncrypt();
// 设置公钥
encryptor.setPublicKey(publicKey);
// 加密数据
return encryptor.encrypt(uuid);

解密

let decrypt = new JSEncrypt()
decrypt.setPrivateKey(privateKey)
return decrypt.decrypt(msg)
Last Updated:
Contributors: haizhiguang