jsencrypt进行rsa加密

 

安装

npm i jsencrypt --save

  cnpm i encryptlong -S

引入

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)

  

posted @ 2022-06-24 15:42  非帆丶  阅读(420)  评论(0编辑  收藏  举报