修改消息模板加密方式

This commit is contained in:
fengachen
2021-09-23 14:05:54 +08:00
parent 06f9637461
commit 792c480de6
2 changed files with 18 additions and 15 deletions
+4 -1
View File
@@ -112,6 +112,8 @@ export const transitRESTful = {
const getContactsByCompany = (params) => getAction('/company/payContactsManagement/queryByCompanyMeeting', params)
// 通过联系人id获取联系人信息
const getContactsById = (param) => getAction('/company/payContactsManagement/queryByIdMeeting', param)
// 加密获取key 与 iv
const getKeyIv = (param) => getAction('/sys/getEncryptedString',param)
export {
addRole,
@@ -173,7 +175,8 @@ export {
getContactsByCompany,
queryallRoles,
getContactsById,
getFileInfo
getFileInfo,
getKeyIv
}
@@ -85,8 +85,8 @@
import pick from 'lodash.pick'
import { duplicateCheck } from '@/api/api'
import JEditor from '@/components/jero/JEditor'
import {getRSAPublicKey} from '@/api/login.js'
import {JSEncrypt} from 'jsencrypt'
import { encryption } from '@/utils/encryption/aesEncrypt'
import { getKeyIv } from '@/api/api'
export default {
name: 'SysMessageTemplateModal',
@@ -123,7 +123,11 @@
useEditor:false,
templateEditorContent:'',
// 加密公钥
rsaPublicKey:''
rsaPublicKey:'',
// 加密要的key
key:'',
// 加密要的iv
iv:''
}
},
created() {
@@ -135,7 +139,7 @@
},
edit(record) {
this.form.resetFields()
this.getPublicKey()
this.getKey()
this.model = Object.assign({}, record)
this.useEditor = (record.templateType==2 || record.templateType==4)
if(this.useEditor){
@@ -175,11 +179,8 @@
//时间格式化
if(this.useEditor){
formData.rsaPublicKey = that.rsaPublicKey
let encrypt = new JSEncrypt()
encrypt.setPublicKey(formData.rsaPublicKey)
// 公钥加密
formData.templateContent = encrypt.encrypt(this.templateEditorContent)
// 加密
formData.templateContent = encryption(this.templateEditorContent,this.key,this.iv)
// formData.templateContent=this.templateEditorContent
}
console.log(formData)
@@ -199,11 +200,10 @@
}
})
},
//获取RSA公钥
getPublicKey(){
// 获取公钥
getRSAPublicKey().then(res => {
this.rsaPublicKey = res.result
getKey(){
getKeyIv().then(res => {
this.key = res.result.key
this.iv = res.result.iv
})
},
validateTemplateCode(rule, value, callback){