Commit cf21a820 by 王昆

gsb

parent 57841628
...@@ -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
......
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