123456789101112131415161718 |
- import JSEncrypt from '@/node_modules/jsencrypt/bin/jsencrypt.js'
- import {
- getPubKey
- } from '@/utils/auth.js'
- //获取公钥
- const publickey = getPubKey()
- export function encrypt(txt) {
- if(!publickey){
- return "";
- }
- const encryptor = new JSEncrypt()
- // 设置公钥
- encryptor.setPublicKey(publickey)
- // 对数据进行加密
- return encryptor.encrypt(txt.toString())
- }
|