jsencrypt.js 346 B

123456789101112131415
  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. const encryptor = new JSEncrypt()
  9. // 设置公钥
  10. encryptor.setPublicKey(publickey)
  11. // 对数据进行加密
  12. return encryptor.encrypt(txt.toString())
  13. }