Commit 3e2b076a authored by 张锡奇's avatar 张锡奇

upload

parent 3f9a99e0
......@@ -52,7 +52,6 @@
"clipboard": "^2.0.4",
"copy-webpack-plugin": "^4.0.1",
"cross-spawn": "^5.0.1",
"crypto-js": "^3.3.0",
"css-loader": "^0.28.0",
"echarts": "^4.2.1",
"extract-text-webpack-plugin": "^3.0.0",
......
......@@ -9,16 +9,6 @@ nowYear += (nowYear < 2000) ? 1900 : 0; //
var y = 0;
const fillKey = (key) => {
const filledKey = Buffer.alloc(128 / 8);
const keys = Buffer.from(key);
if (keys.length <= filledKey.length) {
filledKey.map((b, i) => filledKey[i] = keys[i]);
}
return filledKey;
}
let util = {
};
......@@ -537,32 +527,4 @@ util.scrollToBottom = function(scrollDom){
// }
// }
/**
* 定义加密函数
* @param {string} data - 需要加密的数据, 传过来前先进行 JSON.stringify(data);
* @param {string} key - 加密使用的 key
*/
util.aesEncrypt = (data, key) => {
key = CryptoJS.enc.Utf8.parse(fillKey(key));
/**
* CipherOption, 加密的一些选项:
* mode: 加密模式, 可取值(CBC, CFB, CTR, CTRGladman, OFB, ECB), 都在 CryptoJS.mode 对象下
* padding: 填充方式, 可取值(Pkcs7, AnsiX923, Iso10126, Iso97971, ZeroPadding, NoPadding), 都在 CryptoJS.pad 对象下
* iv: 偏移量, mode === ECB 时, 不需要 iv
* 返回的是一个加密对象
*/
const cipher = CryptoJS.AES.encrypt(data, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
iv: "",
});
// 将加密后的数据转换成 Base64
const base64Cipher = cipher.ciphertext.toString(CryptoJS.enc.Base64);
// 处理 Android 某些低版的BUG
const resultCipher = base64Cipher.replace(/\+/g,"-").replace(/\//g,"_");
// 返回加密后的经过处理的 Base64
return cipher.toString();
}
export default util;
\ No newline at end of file
......@@ -175,7 +175,6 @@ export default {
this.routerToDetail();
})
console.log(Util.aesEncrypt('1234567890123456', '1234567890123456'));
// let result = await this.request('get_ticket',{
// data:{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment