mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-12 13:46:43 +08:00
随机密码加密解密--v2环境,封装加密解密的方法
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import axios from 'axios'
|
||||
// import AESTools from '@/assets/js/utils/cryptoJsUtil'
|
||||
import {
|
||||
MD5,
|
||||
RSAEncrypt,
|
||||
AESEncryptV2,
|
||||
AESDecryptV2,
|
||||
AESEncrypt,
|
||||
AESDecrypt,
|
||||
randomString,
|
||||
@@ -165,6 +166,8 @@ service.interceptors.request.use(
|
||||
masterKey = window.localStorage.getItem('masterKey')
|
||||
}
|
||||
}
|
||||
// token 不存在初始化处理
|
||||
let token = CacheUtils.getLocItem('token')
|
||||
/**
|
||||
* 请求拦截处理(待添加 判断走统一网关处理)
|
||||
*/
|
||||
@@ -197,14 +200,13 @@ service.interceptors.request.use(
|
||||
console.log(AESDecrypt(config.data.data, masterKey));
|
||||
}
|
||||
}else if(configApp.API_VERSION == 'v2'){
|
||||
let encrypt = AESEncrypt(JSON.stringify(config.data), configApp.REQ_PWD)
|
||||
config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'))
|
||||
let encrypt = AESEncryptV2(JSON.stringify(config.data), configApp.REQ_PWD)
|
||||
config.data = { data: encrypt }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// token 不存在初始化处理
|
||||
let token = CacheUtils.getLocItem('token')
|
||||
if (!token) {
|
||||
console.log('token====>>', token)
|
||||
// 设备类型
|
||||
@@ -230,7 +232,6 @@ service.interceptors.request.use(
|
||||
// 添加请时间戳
|
||||
let timeStr = new Date().getTime() + ''
|
||||
config.headers['timeStr'] = timeStr
|
||||
// config.headers['signature'] = MD5(timeStr + CacheUtils.getLocItem('token'))
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
@@ -266,7 +267,8 @@ service.interceptors.response.use(
|
||||
res = JSON.parse(AESDecrypt(res.response, masterKey))
|
||||
}else if(configApp.API_VERSION == 'v2'){
|
||||
// 使用固定密钥解密返回结果data
|
||||
res = JSON.parse(AESDecrypt(res.response, configApp.REQ_PWD))
|
||||
res = JSON.parse(AESDecryptV2(res.response, configApp.REQ_PWD))
|
||||
console.log(res,'JSON.parse(AESDecrypt(res.response, configApp.REQ_PWD))')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user