开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 1492|回复: 1
收起左侧

[js/PHP求助] 关于JS的一个问题

[复制链接]
结帖率:60% (12/20)
发表于 2012-12-9 03:41:38 | 显示全部楼层 |阅读模式   山东省临沂市
迅雷网站登录的JS加密 最后的加密结果和VIP教程里面的相同
但不和提交的数据里相同   是什么情况?来人解答下吧  = =。。
是教程里错了 还是我做错了?


登录网站:http://i.xunlei.com/login.html

hex_md5("1")
-->返回类型:文本型
-->计算结果:c4ca4238a0b923820dcc509a6f75849b
  1. var chrsz = 8;
  2. var hexcase = 0;
  3. function hex_md5(s) {
  4. return binl2hex(core_md5(str2binl(s), s.length * chrsz));
  5. }
  6. function b64_md5(s) {
  7. return binl2b64(core_md5(str2binl(s), s.length * chrsz));
  8. }
  9. function str_md5(s) {
  10. return binl2str(core_md5(str2binl(s), s.length * chrsz));
  11. }
  12. function hex_hmac_md5(key, data) {
  13. return binl2hex(core_hmac_md5(key, data));
  14. }
  15. function b64_hmac_md5(key, data) {
  16. return binl2b64(core_hmac_md5(key, data));
  17. }
  18. function str_hmac_md5(key, data) {
  19. return binl2str(core_hmac_md5(key, data));
  20. }

  21. /*
  22. * Perform a simple self-test to see if the VM is working
  23. */
  24. function md5_vm_test() {
  25. return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  26. }

  27. /*
  28. * Calculate the MD5 of an array of little-endian words, and a bit length
  29. */
  30. function core_md5(x, len) {
  31. /* append padding */
  32. x[len >> 5] |= 0x80 << ((len) % 32);
  33. x[(((len + 64) >>> 9) << 4) + 14] = len;

  34. var a = 1732584193;
  35. var b = -271733879;
  36. var c = -1732584194;
  37. var d = 271733878;

  38. for (var i = 0; i < x.length; i += 16) {
  39. var olda = a;
  40. var oldb = b;
  41. var oldc = c;
  42. var oldd = d;

  43. a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
  44. d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
  45. c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
  46. b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
  47. a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
  48. d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
  49. c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
  50. b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
  51. a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
  52. d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
  53. c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
  54. b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
  55. a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
  56. d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
  57. c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
  58. b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);

  59. a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
  60. d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
  61. c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
  62. b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
  63. a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
  64. d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
  65. c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
  66. b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
  67. a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
  68. d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
  69. c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
  70. b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
  71. a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
  72. d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
  73. c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
  74. b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);

  75. a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
  76. d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
  77. c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
  78. b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
  79. a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
  80. d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
  81. c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
  82. b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
  83. a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
  84. d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
  85. c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
  86. b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
  87. a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
  88. d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
  89. c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
  90. b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);

  91. a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
  92. d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
  93. c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
  94. b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
  95. a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
  96. d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
  97. c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
  98. b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
  99. a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
  100. d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
  101. c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
  102. b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
  103. a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
  104. d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
  105. c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
  106. b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);

  107. a = safe_add(a, olda);
  108. b = safe_add(b, oldb);
  109. c = safe_add(c, oldc);
  110. d = safe_add(d, oldd);
  111. }
  112. return Array(a, b, c, d);

  113. }

  114. /*
  115. * These functions implement the four basic operations the algorithm uses.
  116. */
  117. function md5_cmn(q, a, b, x, s, t) {
  118. return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
  119. }
  120. function md5_ff(a, b, c, d, x, s, t) {
  121. return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  122. }
  123. function md5_gg(a, b, c, d, x, s, t) {
  124. return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  125. }
  126. function md5_hh(a, b, c, d, x, s, t) {
  127. return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  128. }
  129. function md5_ii(a, b, c, d, x, s, t) {
  130. return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  131. }

  132. /*
  133. * Calculate the HMAC-MD5, of a key and some data
  134. */
  135. function core_hmac_md5(key, data) {
  136. var bkey = str2binl(key);
  137. if (bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);

  138. var ipad = Array(16),
  139. opad = Array(16);
  140. for (var i = 0; i < 16; i++) {
  141. ipad[i] = bkey[i] ^ 0x36363636;
  142. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  143. }

  144. var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  145. return core_md5(opad.concat(hash), 512 + 128);
  146. }

  147. /*
  148. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  149. * to work around bugs in some JS interpreters.
  150. */
  151. function safe_add(x, y) {
  152. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  153. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  154. return (msw << 16) | (lsw & 0xFFFF);
  155. }

  156. /*
  157. * Bitwise rotate a 32-bit number to the left.
  158. */
  159. function bit_rol(num, cnt) {
  160. return (num << cnt) | (num >>> (32 - cnt));
  161. }

  162. /*
  163. * Convert a string to an array of little-endian words
  164. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  165. */
  166. function str2binl(str) {
  167. var bin = Array();
  168. var mask = (1 << chrsz) - 1;
  169. for (var i = 0; i < str.length * chrsz; i += chrsz) bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32);
  170. return bin;
  171. }

  172. /*
  173. * Convert an array of little-endian words to a string
  174. */
  175. function binl2str(bin) {
  176. var str = "";
  177. var mask = (1 << chrsz) - 1;
  178. for (var i = 0; i < bin.length * 32; i += chrsz) str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) & mask);
  179. return str;
  180. }

  181. /*
  182. * Convert an array of little-endian words to a hex string.
  183. */
  184. function binl2hex(binarray) {
  185. var hex_tab = hexcase ? "0123456789ABCDEF": "0123456789abcdef";
  186. var str = "";
  187. for (var i = 0; i < binarray.length * 4; i++) {
  188. str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) + hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
  189. }
  190. return str;
  191. }

  192. /*
  193. * Convert an array of little-endian words to a base-64 string
  194. */
  195. function binl2b64(binarray) {
  196. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  197. var str = "";
  198. for (var i = 0; i < binarray.length * 4; i += 3) {
  199. var triplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 0xFF) << 16) | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 0xFF) << 8) | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 0xFF);
  200. for (var j = 0; j < 4; j++) {
  201. if (i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  202. else str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
  203. }
  204. }
  205. return str;
  206. }
复制代码

本帖被以下淘专辑推荐:

结帖率:33% (3/9)
发表于 2012-12-9 03:45:24 | 显示全部楼层   四川省乐山市
哈哈...按照网站
JS编写JS代码

点评

彗星 浏览器 可以看JS源   四川省乐山市  发表于 2012-12-9 03:45
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表