gamen.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. var gamen = {};
  2. (function () {
  3. var XORcipher = function () {
  4. return new XORcipher.fn.init();
  5. };
  6. XORcipher.fn = XORcipher.prototype =
  7. {
  8. constructor: XORcipher,
  9. init:function()
  10. {
  11. return this;
  12. },
  13. //암호화
  14. xorEncoder:function($str, $key)
  15. {
  16. var bytes = [];
  17. for (var i = 0; i < $str.length; ++i)
  18. {
  19. bytes.push($str.charCodeAt(i));
  20. }
  21. var result = [];
  22. for(var i = 0; i < bytes.length; i++)
  23. {
  24. result.push(bytes[i] ^ $key);
  25. }
  26. return result;
  27. },
  28. //복호화
  29. xorDecoder:function($byte, $key)
  30. {
  31. var bytes = [];
  32. for(var i = 0; i < $byte.length; i++)
  33. {
  34. bytes.push($byte[i] ^ $key);
  35. }
  36. var str = String.fromCharCode.apply(String, bytes);
  37. return str;
  38. }
  39. };
  40. window.XORcipher = XORcipher;
  41. }());
  42. XORcipher.fn.init.prototype = XORcipher.fn;
  43. gamen.start = function ($returnFunc){
  44. var skey = 999;
  45. var okey = 888;
  46. //Encrypt pk value
  47. var pk = XORcipher().xorEncoder("abcd144223", skey);
  48. //Unique Value Encryption
  49. var uniqu = XORcipher().xorEncoder("chadol0202", skey);
  50. //Convert the server's key value to bytes
  51. var skeyStr = skey.toString();
  52. var bytes0 = [];
  53. for (var i = 0; i < skeyStr.length; ++i){
  54. bytes0.push(skeyStr.charCodeAt(i));
  55. }
  56. var okeyStr = okey.toString();
  57. var bytes1 = [];
  58. for (i = 0; i < okeyStr.length; ++i){
  59. bytes1.push(okeyStr.charCodeAt(i));
  60. }
  61. //Achievement information
  62. gamen.achievement = [];
  63. gamen.achievement[0] = XORcipher().xorEncoder("1_gamen_1_gamen_23,52,30_gamen_set_gamen_res/game_medal_0001.png_gamen_0", 999);
  64. gamen.achievement[1] = XORcipher().xorEncoder("2_gamen_1_gamen_23,52,30_gamen_set_gamen_res/game_medal_0002.png_gamen_0", 999);
  65. gamen.achievement[2] = XORcipher().xorEncoder("3_gamen_1_gamen_23,52,30_gamen_set_gamen_res/game_medal_0003.png_gamen_0", 999);
  66. gamen.achievement[3] = XORcipher().xorEncoder("4_gamen_1_gamen_23,52,30_gamen_set_gamen_res/game_medal_0004.png_gamen_0", 999);
  67. return $returnFunc(true, uniqu, pk, bytes0, bytes1);
  68. };
  69. gamen.point = function($type, $point, $time){};
  70. gamen.otherpoint = function($type, $point, $time){};
  71. gamen.finish = function ($pk, $score, $returnFunc, $uniq, $sTime, $eTime, $synchroKey){
  72. //Convert key value from byte to number
  73. var skey = Math.floor(String.fromCharCode.apply(String, $synchroKey));
  74. skey = 999;
  75. //pk decoding
  76. var pk = XORcipher().xorDecoder($pk, skey);
  77. //Total score decoding
  78. var score = XORcipher().xorDecoder($score, skey);
  79. //Decoding return function
  80. //var returnFunc = XORcipher().xorDecoder($returnFunc, skey);
  81. var returnFunc = $returnFunc;
  82. //Rank encryption
  83. var rankNum = 123;
  84. var rank = XORcipher().xorEncoder(rankNum.toString(), skey);
  85. return returnFunc(false, rank);
  86. };
  87. gamen.loadend = function(){};
  88. gamen.pointstatuscheck = function(){};
  89. gamen.promiseplay = function(){};
  90. gamen.spkey = function($num){
  91. return Math.floor(String.fromCharCode.apply(String, $num));
  92. };
  93. gamen.opkey = function($num){
  94. return $num;
  95. };
  96. //External service availability
  97. gamen.score_view_status = false;
  98. gamen.game_language = "cn";
  99. module.exports = gamen;