Commit 12745049 by 孙亚楠

d

parent c3008706
......@@ -77,7 +77,7 @@ class TestAPI extends APIBase {
}
let openID = "gtbh5_" + obj.mobile;
let merchant_id = decodeURIComponent(obj.merchant_id);
let merchant_id = system.decryption(obj.merchant_id);
let params = {
saas_merchant_id: merchant_id,
saas_id: null,
......@@ -102,7 +102,8 @@ class TestAPI extends APIBase {
//验证登录
async loginUser(obj) {
let merchant_id = decodeURIComponent(obj.merchant_id);
// let merchant_id = decodeURIComponent(obj.merchant_id);
let merchant_id = system.decryption(obj.merchant_id);
let user = await this.getLoginUser(merchant_id, obj.openid);
return this.returnSuccess(user);
}
......
......@@ -217,6 +217,40 @@ class System {
}
}
}
static encryption(data) {
if(!data) {
return "";
}
let AES_conf = settings.apiconfig.AES;
let key = AES_conf.key;
let iv = AES_conf.iv;
// let padding = AES_conf.padding;
var cipherChunks = [];
var cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
cipher.setAutoPadding(true);
cipherChunks.push(cipher.update(data, 'utf8', 'base64'));
cipherChunks.push(cipher.final('base64'));
return cipherChunks.join('');
}
static decryption(data){
if(!data) {
return "";
}
let AES_conf = settings.apiconfig.AES;
let key = AES_conf.key;
let iv = AES_conf.iv;
// let padding = AES_conf.padding;
var cipherChunks = [];
var decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);
decipher.setAutoPadding(true);
cipherChunks.push(decipher.update(data, 'base64', 'utf8'));
cipherChunks.push(decipher.final('utf8'));
return cipherChunks.join('');
}
}
Date.prototype.Format = function (fmt) { //author: meizz
......
......@@ -60,6 +60,11 @@ var settings = {
opLogEsIsAdd: function () {
return 1;
},
AES: {
key: "qUPsMflPfgpPP1Ua", //密钥
iv: '1012133205963708', //偏移向量
padding: 'PKCS7Padding' //补全值
}
},
indexPage: function() {
if(this.env == "dev") {
......
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