Commit deb9a017 by 焦子成

Merge branch 'bpo-admin' of gitlab.gongsibao.com:jiangyong/zhichan into bpo-admin

parents 58bdb349 cf21a820
...@@ -13,6 +13,23 @@ class TestApi { ...@@ -13,6 +13,23 @@ class TestApi {
this.dkcontractSve = System.getObject("service.dkcontractSve"); this.dkcontractSve = System.getObject("service.dkcontractSve");
} }
async testaes(obj) {
let str = '{"channel_id": "11111", "platform_channel_id": "1asdqqwdwqdwqdwqddqdwq", "channel_merchant_id": "211111", "origin_merchant_id": "11112312wqdwqdwqwqd", "data_id": "11221321321dwwqwqdwq1"}';
console.log(`字符串: ${str}`);
let encry = System.encryption(str);
console.log(`加密: ${encry}`);
let params = encodeURIComponent(encry);
console.log(`生成参数: ${params}`);
let decry = System.decryption(encry);
console.log(`解密: ${decry}`);
}
async genPosterQrcodeImg(obj) { async genPosterQrcodeImg(obj) {
return await this.imghandleApi.genPosterQrcodeImg(obj.qrcode, obj.bakImg); return await this.imghandleApi.genPosterQrcodeImg(obj.qrcode, obj.bakImg);
} }
......
var fs=require("fs"); var fs=require("fs");
var objsettings=require("../config/objsettings"); var objsettings=require("../config/objsettings");
var settings=require("../config/settings"); var settings=require("../config/settings");
const crypto = require('crypto');
class System { class System {
static declare(ns) { static declare(ns) {
var ar = ns.split('.'); var ar = ns.split('.');
...@@ -271,6 +273,40 @@ class System { ...@@ -271,6 +273,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) Date.prototype.Format = function(fmt)
{ //author: meizz { //author: meizz
......
...@@ -30,6 +30,11 @@ var settings = { ...@@ -30,6 +30,11 @@ var settings = {
} }
}, },
apiconfig: { apiconfig: {
AES: {
key: "qUPsMflPfgpPP1Ua", //密钥
iv: '1012133205963708', //偏移向量
padding: 'PKCS7Padding' //补全值
},
opLogUrl: function () { opLogUrl: function () {
return settings.reqEsAddr() + "bigdata_zc_op_log/_doc?pretty"; return settings.reqEsAddr() + "bigdata_zc_op_log/_doc?pretty";
}, },
......
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