123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- var gamen = {};
- (function () {
- var XORcipher = function () {
- return new XORcipher.fn.init();
- };
- XORcipher.fn = XORcipher.prototype =
- {
- constructor: XORcipher,
- init:function()
- {
- return this;
- },
- //암호화
- xorEncoder:function($str, $key)
- {
- var bytes = [];
- for (var i = 0; i < $str.length; ++i)
- {
- bytes.push($str.charCodeAt(i));
- }
- var result = [];
- for(var i = 0; i < bytes.length; i++)
- {
- result.push(bytes[i] ^ $key);
- }
- return result;
- },
- //복호화
- xorDecoder:function($byte, $key)
- {
- var bytes = [];
- for(var i = 0; i < $byte.length; i++)
- {
- bytes.push($byte[i] ^ $key);
- }
- var str = String.fromCharCode.apply(String, bytes);
- return str;
- }
- };
- window.XORcipher = XORcipher;
- }());
- XORcipher.fn.init.prototype = XORcipher.fn;
- gamen.start = function ($returnFunc){
- var skey = 999;
- var okey = 888;
- //Encrypt pk value
- var pk = XORcipher().xorEncoder("abcd144223", skey);
- //Unique Value Encryption
- var uniqu = XORcipher().xorEncoder("chadol0202", skey);
- //Convert the server's key value to bytes
- var skeyStr = skey.toString();
- var bytes0 = [];
- for (var i = 0; i < skeyStr.length; ++i){
- bytes0.push(skeyStr.charCodeAt(i));
- }
- var okeyStr = okey.toString();
- var bytes1 = [];
- for (i = 0; i < okeyStr.length; ++i){
- bytes1.push(okeyStr.charCodeAt(i));
- }
- //Achievement information
- gamen.achievement = [];
- gamen.achievement[0] = XORcipher().xorEncoder("1_gamen_1_gamen_23,52,30_gamen_set_gamen_res/game_medal_0001.png_gamen_0", 999);
- gamen.achievement[1] = XORcipher().xorEncoder("2_gamen_1_gamen_23,52,30_gamen_set_gamen_res/game_medal_0002.png_gamen_0", 999);
- gamen.achievement[2] = XORcipher().xorEncoder("3_gamen_1_gamen_23,52,30_gamen_set_gamen_res/game_medal_0003.png_gamen_0", 999);
- gamen.achievement[3] = XORcipher().xorEncoder("4_gamen_1_gamen_23,52,30_gamen_set_gamen_res/game_medal_0004.png_gamen_0", 999);
- return $returnFunc(true, uniqu, pk, bytes0, bytes1);
- };
- gamen.point = function($type, $point, $time){};
- gamen.otherpoint = function($type, $point, $time){};
- gamen.finish = function ($pk, $score, $returnFunc, $uniq, $sTime, $eTime, $synchroKey){
- //Convert key value from byte to number
- var skey = Math.floor(String.fromCharCode.apply(String, $synchroKey));
- skey = 999;
- //pk decoding
- var pk = XORcipher().xorDecoder($pk, skey);
- //Total score decoding
- var score = XORcipher().xorDecoder($score, skey);
- //Decoding return function
- //var returnFunc = XORcipher().xorDecoder($returnFunc, skey);
- var returnFunc = $returnFunc;
- //Rank encryption
- var rankNum = 123;
- var rank = XORcipher().xorEncoder(rankNum.toString(), skey);
- return returnFunc(false, rank);
- };
- gamen.loadend = function(){};
- gamen.pointstatuscheck = function(){};
- gamen.promiseplay = function(){};
- gamen.spkey = function($num){
- return Math.floor(String.fromCharCode.apply(String, $num));
- };
- gamen.opkey = function($num){
- return $num;
- };
- //External service availability
- gamen.score_view_status = false;
- gamen.game_language = "cn";
- module.exports = gamen;
|