Commit 72c201a6 by 孙亚楠

Merge branch 'xgg-saas-platform' of gitlab.gongsibao.com:jiangyong/zhichan into xgg-saas-platform

parents e16e2d99 d294dc5b
var fs = require("fs"); const fs = require("fs");
var objsettings = require("../config/objsettings"); const objsettings = require("../config/objsettings");
var settings = require("../config/settings"); const settings = require("../config/settings");
const crypto = require("crypto");
class System { class System {
static declare(ns) { static declare(ns) {
...@@ -219,6 +220,40 @@ class System { ...@@ -219,6 +220,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 Date.prototype.Format = function (fmt) { //author: meizz
......
...@@ -55,6 +55,11 @@ var settings = { ...@@ -55,6 +55,11 @@ var settings = {
opLogEsIsAdd: function () { opLogEsIsAdd: function () {
return 1; return 1;
}, },
AES: {
key: "qUPsMflPfgpPP1Ua", //密钥
iv: '1012133205963708', //偏移向量
padding: 'PKCS7Padding' //补全值
}
}, },
indexPage: function() { indexPage: function() {
if(this.env == "dev") { 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