jsencrypt.js 379 B

123456789101112131415161718
  1. import JSEncrypt from '@/node_modules/jsencrypt/bin/jsencrypt.js'
  2. import {
  3. getPubKey
  4. } from '@/utils/auth.js'
  5. //获取公钥
  6. const publickey = getPubKey()
  7. export function encrypt(txt) {
  8. if(!publickey){
  9. return "";
  10. }
  11. const encryptor = new JSEncrypt()
  12. // 设置公钥
  13. encryptor.setPublicKey(publickey)
  14. // 对数据进行加密
  15. return encryptor.encrypt(txt.toString())
  16. }