Commit 42f0d642 authored by zhangjinzhou's avatar zhangjinzhou

暂存提交加密

parent f2edbe76
...@@ -34,7 +34,10 @@ ...@@ -34,7 +34,10 @@
data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="false" data-content-height="1624" data-multi-fingered="2" data-show-fps="false" data-show-log="false"
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"> data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div> </div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/db_games/libs/aes.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/db_games/libs/pad-zeropadding.js"></script>
<script src="libs/modules/egret/egret.js"></script> <script src="libs/modules/egret/egret.js"></script>
<script src="libs/modules/egret/egret.web.js"></script> <script src="libs/modules/egret/egret.web.js"></script>
<script src="libs/modules/eui/eui.js"></script> <script src="libs/modules/eui/eui.js"></script>
......
...@@ -20,7 +20,7 @@ export abstract class ABNetManager { ...@@ -20,7 +20,7 @@ export abstract class ABNetManager {
* 发送请求 * 发送请求
* @param net * @param net
*/ */
public send(net: INetData): void { public send(net: INetData,header=null): void {
let gTime: string = '?_=' + GTime.getTimestamp(); let gTime: string = '?_=' + GTime.getTimestamp();
let realUrl: string = net.uri; let realUrl: string = net.uri;
if (realUrl.indexOf('?') != -1) { if (realUrl.indexOf('?') != -1) {
...@@ -32,6 +32,28 @@ export abstract class ABNetManager { ...@@ -32,6 +32,28 @@ export abstract class ABNetManager {
realUrl += net.addUrl; realUrl += net.addUrl;
} }
// console.log(`[send][${net.uri}]${JSON.stringify(net.param)}`) // console.log(`[send][${net.uri}]${JSON.stringify(net.param)}`)
//提交专门处理header
if(header){
window['$'].ajax({
type: net.type,
// url: realUrl + gTime,
url: realUrl,
headers: {
"Hdtool-Content": header
},
dataType: net.dataType,
data: net.param,
async: true,
success: (result) => {
// console.log(`[success][${net.uri}]${JSON.stringify(result)}`)
this.onResponse(net, result);
},
error: (message) => {
this.onError(net);
}
});
return;
}
window['$'].ajax({ window['$'].ajax({
type: net.type, type: net.type,
// url: realUrl + gTime, // url: realUrl + gTime,
......
...@@ -416,9 +416,58 @@ export class NetManager extends ABNetManager { ...@@ -416,9 +416,58 @@ export class NetManager extends ABNetManager {
sgin: sign, sgin: sign,
dynamicData: JSON.stringify(dynamicData) dynamicData: JSON.stringify(dynamicData)
}; };
function createSgin(ticketId, score, gameData, submitToken) {
return window['duiba_md5'](ticketId + '' + score + '' + gameData + '' + submitToken);
}
function encrypt(data) {
//约定的键值
var kk = (+window['CFG'].consumerId).toString(32)
kk = kk.substring(0, 16);
//补0;
var len = kk.length;
while (len < 16) {
kk = kk + "0";
len++;
}
//约定iv
var ii = (+window['CFG'].consumerId).toString(16)
ii = ii.substring(0, 16);
//补0;
var len = ii.length;
while (len < 16) {
ii = ii + "0";
len++;
}
var CryptoJS = window["CryptoJS"];
var key = CryptoJS.enc.Utf8.parse(kk);
var iv = CryptoJS.enc.Utf8.parse(ii);
return CryptoJS.AES.encrypt(JSON.stringify(data), key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.ZeroPadding
}).toString();
}
let pp = {
orderId,
score,
gameData,
sign,
dynamicData,
rankId
}
if (rankId) { if (rankId) {
param.rankId = rankId; param.rankId = rankId;
pp["rankId"] = rankId;
} }
//加密拼参数
pp = encrypt(pp);
const net: INetData = { const net: INetData = {
name: 'ngameSubmit', name: 'ngameSubmit',
uri: '/hdtool/recon/ngame/ngameSubmit', uri: '/hdtool/recon/ngame/ngameSubmit',
...@@ -428,7 +477,7 @@ export class NetManager extends ABNetManager { ...@@ -428,7 +477,7 @@ export class NetManager extends ABNetManager {
hideMsg: true, hideMsg: true,
callback: callback callback: callback
}; };
this.send(net); this.send(net, pp);
} }
getOrderStatus(callback: Function, orderId: number, pollingCheck?: Function, pollingCount = 10): void { getOrderStatus(callback: Function, orderId: number, pollingCheck?: Function, pollingCount = 10): void {
...@@ -752,13 +801,13 @@ export class NetManager extends ABNetManager { ...@@ -752,13 +801,13 @@ export class NetManager extends ABNetManager {
this.send(net); this.send(net);
} }
public reportMusic(callback: Function,durationOfPlay,songListId,songId,playCount,timestamp,bitrate,songDuration): void { public reportMusic(callback: Function, durationOfPlay, songListId, songId, playCount, timestamp, bitrate, songDuration): void {
const data: any = { const data: any = {
durationOfPlay:durationOfPlay,songListId:songListId,songId:songId,timestamp:timestamp, durationOfPlay: durationOfPlay, songListId: songListId, songId: songId, timestamp: timestamp,
action:7, action: 7,
playCount:playCount, playCount: playCount,
bitrate:bitrate, bitrate: bitrate,
isOnline:1,songDuration:songDuration isOnline: 1, songDuration: songDuration
}; };
// if (categoryID) data.categoryID = categoryID; // if (categoryID) data.categoryID = categoryID;
......
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