暂时去除加密解密方法,运行到app会报错
This commit is contained in:
parent
468c6e9a9b
commit
ff36d048b2
|
|
@ -1,64 +1,3 @@
|
||||||
import { SM4 } from 'gm-crypto'
|
|
||||||
import {encryptKey} from '@/commons/config.js'
|
|
||||||
|
|
||||||
let HEX_KEY = null
|
|
||||||
|
|
||||||
// 字符串转16进制
|
|
||||||
function str2hex(str) {
|
|
||||||
var val = ''
|
|
||||||
for (var i = 0; i < str.length; i++) {
|
|
||||||
if (val == '')
|
|
||||||
val = str.charCodeAt(i).toString(16)
|
|
||||||
else
|
|
||||||
val += str.charCodeAt(i).toString(16)
|
|
||||||
}
|
|
||||||
val += ''
|
|
||||||
return val
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取hex秘钥
|
|
||||||
function getHexKey(){
|
|
||||||
|
|
||||||
if(!HEX_KEY){
|
|
||||||
|
|
||||||
HEX_KEY = str2hex(encryptKey)
|
|
||||||
|
|
||||||
}
|
|
||||||
return HEX_KEY
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 解密 (http响应数据, 做通用处理)
|
|
||||||
export function sm4DecryptByResData(data){
|
export function sm4DecryptByResData(data){
|
||||||
|
return data
|
||||||
if(!data){
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
let res = SM4.decrypt(data, getHexKey(), {
|
|
||||||
inputEncoding: 'base64',
|
|
||||||
outputEncoding: 'utf8'
|
|
||||||
})
|
|
||||||
|
|
||||||
if(!res){
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSON.parse(res)['originData']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加密 (http响应数据, 做通用处理)
|
|
||||||
export function sm4EncryptByReqData(data){
|
|
||||||
if(!data){
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加密处理
|
|
||||||
let encryptData = SM4.encrypt(JSON.stringify(data), getHexKey(), {
|
|
||||||
inputEncoding: 'utf8',
|
|
||||||
outputEncoding: 'base64'
|
|
||||||
})
|
|
||||||
|
|
||||||
return {encryptData : encryptData}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue