- wx.request请求中文编码
wx.request发起的请求中,playload中的字段的中文是通过什么格式编码的?用utf8在服务端对中文字段进行md5编码后和前端生成md5串不一致,求大神解答。。。 md5加密算法如下: [代码]/* [代码][代码] [代码][代码]* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message [代码][代码] [代码][代码]* Digest Algorithm, as defined in RFC 1321. [代码][代码] [代码][代码]* Version 1.1 Copyright (C) Paul Johnston 1999 - 2002. [代码][代码] [代码][代码]* Code also contributed by Greg Holt [代码][代码] [代码][代码]* See http://pajhome.org.uk/site/legal.html for details. [代码][代码] [代码][代码]*/[代码] [代码] [代码] [代码]/* [代码][代码] [代码][代码]* Add integers, wrapping at 2^32. This uses 16-bit operations internally [代码][代码] [代码][代码]* to work around bugs in some JS interpreters. [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]safe_add(x, y) [代码][代码]{ [代码][代码] [代码][代码]var[代码] [代码]lsw = (x & 0xFFFF) + (y & 0xFFFF) [代码][代码] [代码][代码]var[代码] [代码]msw = (x >> 16) + (y >> 16) + (lsw >> 16) [代码][代码] [代码][代码]return[代码] [代码](msw << 16) | (lsw & 0xFFFF) [代码][代码]} [代码][代码] [代码] [代码]/* [代码][代码] [代码][代码]* Bitwise rotate a 32-bit number to the left. [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]rol(num, cnt) [代码][代码]{ [代码][代码] [代码][代码]return[代码] [代码](num << cnt) | (num >>> (32 - cnt)) [代码][代码]} [代码][代码] [代码] [代码]/* [代码][代码] [代码][代码]* These functions implement the four basic operations the algorithm uses. [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]cmn(q, a, b, x, s, t) [代码][代码]{ [代码][代码] [代码][代码]return[代码] [代码]safe_add(rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b) [代码][代码]} [代码][代码]function[代码] [代码]ff(a, b, c, d, x, s, t) [代码][代码]{ [代码][代码] [代码][代码]return[代码] [代码]cmn((b & c) | ((~b) & d), a, b, x, s, t) [代码][代码]} [代码][代码]function[代码] [代码]gg(a, b, c, d, x, s, t) [代码][代码]{ [代码][代码] [代码][代码]return[代码] [代码]cmn((b & d) | (c & (~d)), a, b, x, s, t) [代码][代码]} [代码][代码]function[代码] [代码]hh(a, b, c, d, x, s, t) [代码][代码]{ [代码][代码] [代码][代码]return[代码] [代码]cmn(b ^ c ^ d, a, b, x, s, t) [代码][代码]} [代码][代码]function[代码] [代码]ii(a, b, c, d, x, s, t) [代码][代码]{ [代码][代码] [代码][代码]return[代码] [代码]cmn(c ^ (b | (~d)), a, b, x, s, t) [代码][代码]} [代码][代码] [代码] [代码]/* [代码][代码] [代码][代码]* Calculate the MD5 of an array of little-endian words, producing an array [代码][代码] [代码][代码]* of little-endian words. [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]coreMD5(x) [代码][代码]{ [代码][代码] [代码][代码]var[代码] [代码]a = 1732584193 [代码][代码] [代码][代码]var[代码] [代码]b = -271733879 [代码][代码] [代码][代码]var[代码] [代码]c = -1732584194 [代码][代码] [代码][代码]var[代码] [代码]d = 271733878 [代码][代码] [代码] [代码] [代码][代码]for[代码][代码]([代码][代码]var[代码] [代码]i = 0; i < x.length; i += 16) [代码][代码] [代码][代码]{ [代码][代码] [代码][代码]var[代码] [代码]olda = a [代码][代码] [代码][代码]var[代码] [代码]oldb = b [代码][代码] [代码][代码]var[代码] [代码]oldc = c [代码][代码] [代码][代码]var[代码] [代码]oldd = d [代码][代码] [代码] [代码] [代码][代码]a = ff(a, b, c, d, x[i+ 0], 7 , -680876936) [代码][代码] [代码][代码]d = ff(d, a, b, c, x[i+ 1], 12, -389564586) [代码][代码] [代码][代码]c = ff(c, d, a, b, x[i+ 2], 17, 606105819) [代码][代码] [代码][代码]b = ff(b, c, d, a, x[i+ 3], 22, -1044525330) [代码][代码] [代码][代码]a = ff(a, b, c, d, x[i+ 4], 7 , -176418897) [代码][代码] [代码][代码]d = ff(d, a, b, c, x[i+ 5], 12, 1200080426) [代码][代码] [代码][代码]c = ff(c, d, a, b, x[i+ 6], 17, -1473231341) [代码][代码] [代码][代码]b = ff(b, c, d, a, x[i+ 7], 22, -45705983) [代码][代码] [代码][代码]a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416) [代码][代码] [代码][代码]d = ff(d, a, b, c, x[i+ 9], 12, -1958414417) [代码][代码] [代码][代码]c = ff(c, d, a, b, x[i+10], 17, -42063) [代码][代码] [代码][代码]b = ff(b, c, d, a, x[i+11], 22, -1990404162) [代码][代码] [代码][代码]a = ff(a, b, c, d, x[i+12], 7 , 1804603682) [代码][代码] [代码][代码]d = ff(d, a, b, c, x[i+13], 12, -40341101) [代码][代码] [代码][代码]c = ff(c, d, a, b, x[i+14], 17, -1502002290) [代码][代码] [代码][代码]b = ff(b, c, d, a, x[i+15], 22, 1236535329) [代码][代码] [代码] [代码] [代码][代码]a = gg(a, b, c, d, x[i+ 1], 5 , -165796510) [代码][代码] [代码][代码]d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632) [代码][代码] [代码][代码]c = gg(c, d, a, b, x[i+11], 14, 643717713) [代码][代码] [代码][代码]b = gg(b, c, d, a, x[i+ 0], 20, -373897302) [代码][代码] [代码][代码]a = gg(a, b, c, d, x[i+ 5], 5 , -701558691) [代码][代码] [代码][代码]d = gg(d, a, b, c, x[i+10], 9 , 38016083) [代码][代码] [代码][代码]c = gg(c, d, a, b, x[i+15], 14, -660478335) [代码][代码] [代码][代码]b = gg(b, c, d, a, x[i+ 4], 20, -405537848) [代码][代码] [代码][代码]a = gg(a, b, c, d, x[i+ 9], 5 , 568446438) [代码][代码] [代码][代码]d = gg(d, a, b, c, x[i+14], 9 , -1019803690) [代码][代码] [代码][代码]c = gg(c, d, a, b, x[i+ 3], 14, -187363961) [代码][代码] [代码][代码]b = gg(b, c, d, a, x[i+ 8], 20, 1163531501) [代码][代码] [代码][代码]a = gg(a, b, c, d, x[i+13], 5 , -1444681467) [代码][代码] [代码][代码]d = gg(d, a, b, c, x[i+ 2], 9 , -51403784) [代码][代码] [代码][代码]c = gg(c, d, a, b, x[i+ 7], 14, 1735328473) [代码][代码] [代码][代码]b = gg(b, c, d, a, x[i+12], 20, -1926607734) [代码][代码] [代码] [代码] [代码][代码]a = hh(a, b, c, d, x[i+ 5], 4 , -378558) [代码][代码] [代码][代码]d = hh(d, a, b, c, x[i+ 8], 11, -2022574463) [代码][代码] [代码][代码]c = hh(c, d, a, b, x[i+11], 16, 1839030562) [代码][代码] [代码][代码]b = hh(b, c, d, a, x[i+14], 23, -35309556) [代码][代码] [代码][代码]a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060) [代码][代码] [代码][代码]d = hh(d, a, b, c, x[i+ 4], 11, 1272893353) [代码][代码] [代码][代码]c = hh(c, d, a, b, x[i+ 7], 16, -155497632) [代码][代码] [代码][代码]b = hh(b, c, d, a, x[i+10], 23, -1094730640) [代码][代码] [代码][代码]a = hh(a, b, c, d, x[i+13], 4 , 681279174) [代码][代码] [代码][代码]d = hh(d, a, b, c, x[i+ 0], 11, -358537222) [代码][代码] [代码][代码]c = hh(c, d, a, b, x[i+ 3], 16, -722521979) [代码][代码] [代码][代码]b = hh(b, c, d, a, x[i+ 6], 23, 76029189) [代码][代码] [代码][代码]a = hh(a, b, c, d, x[i+ 9], 4 , -640364487) [代码][代码] [代码][代码]d = hh(d, a, b, c, x[i+12], 11, -421815835) [代码][代码] [代码][代码]c = hh(c, d, a, b, x[i+15], 16, 530742520) [代码][代码] [代码][代码]b = hh(b, c, d, a, x[i+ 2], 23, -995338651) [代码][代码] [代码] [代码] [代码][代码]a = ii(a, b, c, d, x[i+ 0], 6 , -198630844) [代码][代码] [代码][代码]d = ii(d, a, b, c, x[i+ 7], 10, 1126891415) [代码][代码] [代码][代码]c = ii(c, d, a, b, x[i+14], 15, -1416354905) [代码][代码] [代码][代码]b = ii(b, c, d, a, x[i+ 5], 21, -57434055) [代码][代码] [代码][代码]a = ii(a, b, c, d, x[i+12], 6 , 1700485571) [代码][代码] [代码][代码]d = ii(d, a, b, c, x[i+ 3], 10, -1894986606) [代码][代码] [代码][代码]c = ii(c, d, a, b, x[i+10], 15, -1051523) [代码][代码] [代码][代码]b = ii(b, c, d, a, x[i+ 1], 21, -2054922799) [代码][代码] [代码][代码]a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359) [代码][代码] [代码][代码]d = ii(d, a, b, c, x[i+15], 10, -30611744) [代码][代码] [代码][代码]c = ii(c, d, a, b, x[i+ 6], 15, -1560198380) [代码][代码] [代码][代码]b = ii(b, c, d, a, x[i+13], 21, 1309151649) [代码][代码] [代码][代码]a = ii(a, b, c, d, x[i+ 4], 6 , -145523070) [代码][代码] [代码][代码]d = ii(d, a, b, c, x[i+11], 10, -1120210379) [代码][代码] [代码][代码]c = ii(c, d, a, b, x[i+ 2], 15, 718787259) [代码][代码] [代码][代码]b = ii(b, c, d, a, x[i+ 9], 21, -343485551) [代码][代码] [代码] [代码] [代码][代码]a = safe_add(a, olda) [代码][代码] [代码][代码]b = safe_add(b, oldb) [代码][代码] [代码][代码]c = safe_add(c, oldc) [代码][代码] [代码][代码]d = safe_add(d, oldd) [代码][代码] [代码][代码]} [代码][代码] [代码][代码]return[代码] [代码][a, b, c, d] [代码][代码]} [代码][代码] [代码] [代码]/* [代码][代码] [代码][代码]* Convert an array of little-endian words to a hex string. [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]binl2hex(binarray) [代码][代码]{ [代码][代码] [代码][代码]var[代码] [代码]hex_tab = [代码][代码]"0123456789abcdef"[代码] [代码] [代码][代码]var[代码] [代码]str = [代码][代码]""[代码] [代码] [代码][代码]for[代码][代码]([代码][代码]var[代码] [代码]i = 0; i < binarray.length * 4; i++) [代码][代码] [代码][代码]{ [代码][代码] [代码][代码]str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + [代码][代码] [代码][代码]hex_tab.charAt((binarray[i>>2] >> ((i%4)*8)) & 0xF) [代码][代码] [代码][代码]} [代码][代码] [代码][代码]return[代码] [代码]str [代码][代码]} [代码][代码] [代码] [代码]/* [代码][代码] [代码][代码]* Convert an array of little-endian words to a base64 encoded string. [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]binl2b64(binarray) [代码][代码]{ [代码][代码] [代码][代码]var[代码] [代码]tab = [代码][代码]"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[代码] [代码] [代码][代码]var[代码] [代码]str = [代码][代码]""[代码] [代码] [代码][代码]for[代码][代码]([代码][代码]var[代码] [代码]i = 0; i < binarray.length * 32; i += 6) [代码][代码] [代码][代码]{ [代码][代码] [代码][代码]str += tab.charAt(((binarray[i>>5] << (i%32)) & 0x3F) | [代码][代码] [代码][代码]((binarray[i>>5+1] >> (32-i%32)) & 0x3F)) [代码][代码] [代码][代码]} [代码][代码] [代码][代码]return[代码] [代码]str [代码][代码]} [代码][代码] [代码] [代码]/* [代码][代码] [代码][代码]* Convert an 8-bit character string to a sequence of 16-word blocks, stored [代码][代码] [代码][代码]* as an array, and append appropriate padding for MD4/5 calculation. [代码][代码] [代码][代码]* If any of the characters are >255, the high byte is silently ignored. [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]str2binl(str) [代码][代码]{ [代码][代码] [代码][代码]var[代码] [代码]nblk = ((str.length + 8) >> 6) + 1 [代码][代码]// number of 16-word blocks [代码][代码] [代码][代码]var[代码] [代码]blks = [代码][代码]new[代码] [代码]Array(nblk * 16) [代码][代码] [代码][代码]for[代码][代码]([代码][代码]var[代码] [代码]i = 0; i < nblk * 16; i++) blks[i] = 0 [代码][代码] [代码][代码]for[代码][代码]([代码][代码]var[代码] [代码]i = 0; i < str.length; i++) [代码][代码] [代码][代码]blks[i>>2] |= (str.charCodeAt(i) & 0xFF) << ((i%4) * 8) [代码][代码] [代码][代码]blks[i>>2] |= 0x80 << ((i%4) * 8) [代码][代码] [代码][代码]blks[nblk*16-2] = str.length * 8 [代码][代码] [代码][代码]return[代码] [代码]blks [代码][代码]} [代码][代码] [代码] [代码]/* [代码][代码] [代码][代码]* Convert a wide-character string to a sequence of 16-word blocks, stored as [代码][代码] [代码][代码]* an array, and append appropriate padding for MD4/5 calculation. [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]strw2binl(str) [代码][代码]{ [代码][代码] [代码][代码]var[代码] [代码]nblk = ((str.length + 4) >> 5) + 1 [代码][代码]// number of 16-word blocks [代码][代码] [代码][代码]var[代码] [代码]blks = [代码][代码]new[代码] [代码]Array(nblk * 16) [代码][代码] [代码][代码]for[代码][代码]([代码][代码]var[代码] [代码]i = 0; i < nblk * 16; i++) blks[i] = 0 [代码][代码] [代码][代码]for[代码][代码]([代码][代码]var[代码] [代码]i = 0; i < str.length; i++) [代码][代码] [代码][代码]blks[i>>1] |= str.charCodeAt(i) << ((i%2) * 16) [代码][代码] [代码][代码]blks[i>>1] |= 0x80 << ((i%2) * 16) [代码][代码] [代码][代码]blks[nblk*16-2] = str.length * 16 [代码][代码] [代码][代码]return[代码] [代码]blks [代码][代码]} [代码][代码] [代码] [代码]/* [代码][代码] [代码][代码]* External interface [代码][代码] [代码][代码]*/[代码] [代码]function[代码] [代码]hexMD5 (str) { [代码][代码]return[代码] [代码]binl2hex(coreMD5( str2binl(str))) } [代码][代码]function[代码] [代码]hexMD5w(str) { [代码][代码]return[代码] [代码]binl2hex(coreMD5(strw2binl(str))) } [代码][代码]function[代码] [代码]b64MD5 (str) { [代码][代码]return[代码] [代码]binl2b64(coreMD5( str2binl(str))) } [代码][代码]function[代码] [代码]b64MD5w(str) { [代码][代码]return[代码] [代码]binl2b64(coreMD5(strw2binl(str))) } [代码][代码]/* Backward compatibility */[代码] [代码]function[代码] [代码]calcMD5(str) { [代码][代码]return[代码] [代码]binl2hex(coreMD5( str2binl(str))) } [代码][代码]module.exports = { [代码][代码] [代码][代码]hexMD5: hexMD5 [代码][代码]}[代码]
2017-08-25 - wx.request请求
如何验证请求是否来源于小程序(或微信)? 微信的请求是否会进行加密?
2017-08-21 - 安卓手机onBeaconServiceChange触发不正常
iOS上,可以正确读取到每次蓝牙的开启和关闭 Android上,即使没有操作蓝牙开关,也会触发,而开启关闭蓝牙却很大几率不触发这个方法的回调,请尽快修复。
2017-08-17 - 删除小程序,微信马上崩溃
有人遇到么?求解决办法
2017-08-16