bug修改
This commit is contained in:
parent
fab7226afb
commit
bc13169c25
|
|
@ -6,7 +6,7 @@ const cbc_iv = CryptoJS.enc.Utf8.parse('1234567812345678')
|
||||||
* 默认参数需要加密
|
* 默认参数需要加密
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
const encryptEnabled= true;
|
const encryptEnabled= false;
|
||||||
// /**
|
// /**
|
||||||
// * 默认后台会自动加密
|
// * 默认后台会自动加密
|
||||||
// * @type {boolean}
|
// * @type {boolean}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ service.interceptors.request.use(
|
||||||
if (param) {
|
if (param) {
|
||||||
param = param.slice(0, -1)
|
param = param.slice(0, -1)
|
||||||
param = encryptCBC(param)
|
param = encryptCBC(param)
|
||||||
config.headers['Params-Hash'] = hashWithSM3AndSalt(param)
|
/* config.headers['Params-Hash'] = hashWithSM3AndSalt(param) */
|
||||||
}
|
}
|
||||||
config.url = `${config.url}?${param}`
|
config.url = `${config.url}?${param}`
|
||||||
config.params = {}
|
config.params = {}
|
||||||
|
|
@ -80,7 +80,7 @@ service.interceptors.request.use(
|
||||||
config.data = encryptCBC(JSON.stringify(config.data))
|
config.data = encryptCBC(JSON.stringify(config.data))
|
||||||
config.headers['Content-Type'] = 'application/json'
|
config.headers['Content-Type'] = 'application/json'
|
||||||
console.log(config.data)
|
console.log(config.data)
|
||||||
config.headers['Params-Hash'] = hashWithSM3AndSalt(config.data) // 添加数据哈希到请求头
|
/* config.headers['Params-Hash'] = hashWithSM3AndSalt(config.data) */ // 添加数据哈希到请求头
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对下载请求进行数据参数拦截加密
|
// 对下载请求进行数据参数拦截加密
|
||||||
|
|
@ -91,11 +91,11 @@ service.interceptors.request.use(
|
||||||
formData = formData.slice(0, -1)
|
formData = formData.slice(0, -1)
|
||||||
config.data = encryptCBC(formData)
|
config.data = encryptCBC(formData)
|
||||||
console.log(config.data)
|
console.log(config.data)
|
||||||
config.headers['Params-Hash'] = hashWithSM3AndSalt(config.data) // 添加参数哈希到请求头
|
/* config.headers['Params-Hash'] = hashWithSM3AndSalt(config.data) */ // 添加参数哈希到请求头
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
config.data = encryptCBC('formData=' + JSON.stringify(config.data))
|
config.data = encryptCBC('formData=' + JSON.stringify(config.data))
|
||||||
config.headers['Params-Hash'] = hashWithSM3AndSalt(config.data) // 添加参数哈希到请求头
|
/* config.headers['Params-Hash'] = hashWithSM3AndSalt(config.data) */ // 添加参数哈希到请求头
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -190,8 +190,8 @@ export function download(url, params, filename, config) {
|
||||||
return service.post(url, params, {
|
return service.post(url, params, {
|
||||||
transformRequest: [(params) => params],
|
transformRequest: [(params) => params],
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
'Params-Hash': hashWithSM3AndSalt(params)
|
/* 'Params-Hash': hashWithSM3AndSalt(params) */
|
||||||
},
|
},
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
...config
|
...config
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export function hashWithSM3AndSalt(text) {
|
||||||
// 将文本和盐值拼接在一起
|
// 将文本和盐值拼接在一起
|
||||||
const textWithSalt = salt + text
|
const textWithSalt = salt + text
|
||||||
// 使用 SM3 进行哈希
|
// 使用 SM3 进行哈希
|
||||||
return hashSM3(textWithSalt)
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
// SM4 加密
|
// SM4 加密
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue