|
楼主 |
发表于 2019-7-19 14:47:16
|
显示全部楼层
河南省洛阳市
- var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
- var A = new ArrayBuffer(68);
- var l = new Uint8Array(A);
- var d = new Uint32Array(A);
- var n = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
- var userInfo = {
- 'username': 'qingfeng',
- 'password': '123456'
- };
- function Login(userInfo) {
- var t = 'dafacloud_' + Math.random(),
- a = {
- random: encode(t)
- }, n = c(userInfo.username, userInfo.password);
- userInfo.password = s()(n + t);
- userInfo.random = a.random;
- console.log('pwd:' + userInfo.password);
- console.log('random:' + userInfo.random);
- }
- function encode(t, userInfo) {
- return userInfo ? _encode(String(t)).replace(/[+\/]/g, function(t) {
- return '+' == t ? '-' : '_'
- }).replace(/=/g, '') : _encode(String(t))
- }
- function _encode(t) {
- return btoa(utob(t))
- }
- function utob(t) {
- return t.replace(re_utob, cb_utob)
- }
- function cb_utob(t) {
- if (t.length < 2) return (e = t.charCodeAt(0)) < 128 ? t : e < 2048 ? fromCharCode(192 | e >>> 6) + fromCharCode(128 | 63 & e) : fromCharCode(224 | e >>> 12 & 15) + fromCharCode(128 | e >>> 6 & 63) + fromCharCode(128 | 63 & e);
- var e = 65536 + 1024 * (t.charCodeAt(0) - 55296) + (t.charCodeAt(1) - 56320);
- return fromCharCode(240 | e >>> 18 & 7) + fromCharCode(128 | e >>> 12 & 63) + fromCharCode(128 | e >>> 6 & 63) + fromCharCode(128 | 63 & e)
- }
- function c(e, t) {
- return s()(e.toLowerCase() + s()(t))
- }
- function s() {
- return e
- }
- function e(n) {
- return new t(!0).update(n)['hex']()
- }
- function t(t) {
- if (t) d[0] = d[16] = d[1] = d[2] = d[3] = d[4] = d[5] = d[6] = d[7] = d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = 0, this.blocks = d, this.buffer8 = l;
- else if (a) {
- var e = new ArrayBuffer(68);
- this.buffer8 = new Uint8Array(e), this.blocks = new Uint32Array(e)
- } else this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
- this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0, this.finalized = this.hashed = !1, this.first = !0
- }
- t.prototype.update = function(t) {
- var a = true;
- if (!this.finalized) {
- var e, n = typeof t;
- if ("string" !== n) {
- if ("object" !== n) throw r;
- if (null === t) throw r;
- if (a && t.constructor === ArrayBuffer) t = new Uint8Array(t);
- else if (!(Array.isArray(t) || a && ArrayBuffer.isView(t))) throw r;
- e = !0
- }
- for (var i, o, s = 0, l = t.length, c = this.blocks, u = this.buffer8; s < l;) {
- if (this.hashed && (this.hashed = !1, c[0] = c[16], c[16] = c[1] = c[2] = c[3] = c[4] = c[5] = c[6] = c[7] = c[8] = c[9] = c[10] = c[11] = c[12] = c[13] = c[14] = c[15] = 0), e) if (a) for (o = this.start; s < l && o < 64; ++s)
- u[o++] = t[s];
- else for (o = this.start; s < l && o < 64; ++s)
- c[o >> 2] |= t[s] << y[3 & o++];
- else if (a) for (o = this.start; s < l && o < 64; ++s)
- (i = t.charCodeAt(s)) < 128 ? u[o++] = i : i < 2048 ? (u[o++] = 192 | i >> 6, u[o++] = 128 | 63 & i) : i < 55296 || i >= 57344 ? (u[o++] = 224 | i >> 12, u[o++] = 128 | i >> 6 & 63, u[o++] = 128 | 63 & i) : (i = 65536 + ((1023 & i) << 10 | 1023 & t.charCodeAt(++s)), u[o++] = 240 | i >> 18, u[o++] = 128 | i >> 12 & 63, u[o++] = 128 | i >> 6 & 63, u[o++] = 128 | 63 & i);
- else for (o = this.start; s < l && o < 64; ++s)
- (i = t.charCodeAt(s)) < 128 ? c[o >> 2] |= i << y[3 & o++] : i < 2048 ? (c[o >> 2] |= (192 | i >> 6) << y[3 & o++], c[o >> 2] |= (128 | 63 & i) << y[3 & o++]) : i < 55296 || i >= 57344 ? (c[o >> 2] |= (224 | i >> 12) << y[3 & o++], c[o >> 2] |= (128 | i >> 6 & 63) << y[3 & o++], c[o >> 2] |= (128 | 63 & i) << y[3 & o++]) : (i = 65536 + ((1023 & i) << 10 | 1023 & t.charCodeAt(++s)), c[o >> 2] |= (240 | i >> 18) << y[3 & o++], c[o >> 2] |= (128 | i >> 12 & 63) << y[3 & o++], c[o >> 2] |= (128 | i >> 6 & 63) << y[3 & o++], c[o >> 2] |= (128 | 63 & i) << y[3 & o++]);
- this.lastByteIndex = o, this.bytes += o - this.start, o >= 64 ? (this.start = o - 64, this.hash(), this.hashed = !0) : this.start = o
- }
- return this.bytes > 4294967295 && (this.hBytes += this.bytes / 4294967296 << 0, this.bytes = this.bytes % 4294967296), this
- }
- }
- t.prototype.hash = function() {
- var t, e, n, i, r, o, s = this.blocks;
- this.first ? e = ((e = ((t = ((t = s[0] - 680876937) << 7 | t >>> 25) - 271733879 << 0) ^ (n = ((n = (-271733879 ^ (i = ((i = (-1732584194 ^ 2004318071 & t) + s[1] - 117830708) << 12 | i >>> 20) + t << 0) & (-271733879 ^ t)) + s[2] - 1126478375) << 17 | n >>> 15) + i << 0) & (i ^ t)) + s[3] - 1316259209) << 22 | e >>> 10) + n << 0 : (t = this.h0, e = this.h1, n = this.h2, e = ((e += ((t = ((t += ((i = this.h3) ^ e & (n ^ i)) + s[0] - 680876936) << 7 | t >>> 25) + e << 0) ^ (n = ((n += (e ^ (i = ((i += (n ^ t & (e ^ n)) + s[1] - 389564586) << 12 | i >>> 20) + t << 0) & (t ^ e)) + s[2] + 606105819) << 17 | n >>> 15) + i << 0) & (i ^ t)) + s[3] - 1044525330) << 22 | e >>> 10) + n << 0), e = ((e += ((t = ((t += (i ^ e & (n ^ i)) + s[4] - 176418897) << 7 | t >>> 25) + e << 0) ^ (n = ((n += (e ^ (i = ((i += (n ^ t & (e ^ n)) + s[5] + 1200080426) << 12 | i >>> 20) + t << 0) & (t ^ e)) + s[6] - 1473231341) << 17 | n >>> 15) + i << 0) & (i ^ t)) + s[7] - 45705983) << 22 | e >>> 10) + n << 0, e = ((e += ((t = ((t += (i ^ e & (n ^ i)) + s[8] + 1770035416) << 7 | t >>> 25) + e << 0) ^ (n = ((n += (e ^ (i = ((i += (n ^ t & (e ^ n)) + s[9] - 1958414417) << 12 | i >>> 20) + t << 0) & (t ^ e)) + s[10] - 42063) << 17 | n >>> 15) + i << 0) & (i ^ t)) + s[11] - 1990404162) << 22 | e >>> 10) + n << 0, e = ((e += ((t = ((t += (i ^ e & (n ^ i)) + s[12] + 1804603682) << 7 | t >>> 25) + e << 0) ^ (n = ((n += (e ^ (i = ((i += (n ^ t & (e ^ n)) + s[13] - 40341101) << 12 | i >>> 20) + t << 0) & (t ^ e)) + s[14] - 1502002290) << 17 | n >>> 15) + i << 0) & (i ^ t)) + s[15] + 1236535329) << 22 | e >>> 10) + n << 0, e = ((e += ((i = ((i += (e ^ n & ((t = ((t += (n ^ i & (e ^ n)) + s[1] - 165796510) << 5 | t >>> 27) + e << 0) ^ e)) + s[6] - 1069501632) << 9 | i >>> 23) + t << 0) ^ t & ((n = ((n += (t ^ e & (i ^ t)) + s[11] + 643717713) << 14 | n >>> 18) + i << 0) ^ i)) + s[0] - 373897302) << 20 | e >>> 12) + n << 0, e = ((e += ((i = ((i += (e ^ n & ((t = ((t += (n ^ i & (e ^ n)) + s[5] - 701558691) << 5 | t >>> 27) + e << 0) ^ e)) + s[10] + 38016083) << 9 | i >>> 23) + t << 0) ^ t & ((n = ((n += (t ^ e & (i ^ t)) + s[15] - 660478335) << 14 | n >>> 18) + i << 0) ^ i)) + s[4] - 405537848) << 20 | e >>> 12) + n << 0, e = ((e += ((i = ((i += (e ^ n & ((t = ((t += (n ^ i & (e ^ n)) + s[9] + 568446438) << 5 | t >>> 27) + e << 0) ^ e)) + s[14] - 1019803690) << 9 | i >>> 23) + t << 0) ^ t & ((n = ((n += (t ^ e & (i ^ t)) + s[3] - 187363961) << 14 | n >>> 18) + i << 0) ^ i)) + s[8] + 1163531501) << 20 | e >>> 12) + n << 0, e = ((e += ((i = ((i += (e ^ n & ((t = ((t += (n ^ i & (e ^ n)) + s[13] - 1444681467) << 5 | t >>> 27) + e << 0) ^ e)) + s[2] - 51403784) << 9 | i >>> 23) + t << 0) ^ t & ((n = ((n += (t ^ e & (i ^ t)) + s[7] + 1735328473) << 14 | n >>> 18) + i << 0) ^ i)) + s[12] - 1926607734) << 20 | e >>> 12) + n << 0, e = ((e += ((o = (i = ((i += ((r = e ^ n) ^ (t = ((t += (r ^ i) + s[5] - 378558) << 4 | t >>> 28) + e << 0)) + s[8] - 2022574463) << 11 | i >>> 21) + t << 0) ^ t) ^ (n = ((n += (o ^ e) + s[11] + 1839030562) << 16 | n >>> 16) + i << 0)) + s[14] - 35309556) << 23 | e >>> 9) + n << 0, e = ((e += ((o = (i = ((i += ((r = e ^ n) ^ (t = ((t += (r ^ i) + s[1] - 1530992060) << 4 | t >>> 28) + e << 0)) + s[4] + 1272893353) << 11 | i >>> 21) + t << 0) ^ t) ^ (n = ((n += (o ^ e) + s[7] - 155497632) << 16 | n >>> 16) + i << 0)) + s[10] - 1094730640) << 23 | e >>> 9) + n << 0, e = ((e += ((o = (i = ((i += ((r = e ^ n) ^ (t = ((t += (r ^ i) + s[13] + 681279174) << 4 | t >>> 28) + e << 0)) + s[0] - 358537222) << 11 | i >>> 21) + t << 0) ^ t) ^ (n = ((n += (o ^ e) + s[3] - 722521979) << 16 | n >>> 16) + i << 0)) + s[6] + 76029189) << 23 | e >>> 9) + n << 0, e = ((e += ((o = (i = ((i += ((r = e ^ n) ^ (t = ((t += (r ^ i) + s[9] - 640364487) << 4 | t >>> 28) + e << 0)) + s[12] - 421815835) << 11 | i >>> 21) + t << 0) ^ t) ^ (n = ((n += (o ^ e) + s[15] + 530742520) << 16 | n >>> 16) + i << 0)) + s[2] - 995338651) << 23 | e >>> 9) + n << 0, e = ((e += ((i = ((i += (e ^ ((t = ((t += (n ^ (e | ~i)) + s[0] - 198630844) << 6 | t >>> 26) + e << 0) | ~n)) + s[7] + 1126891415) << 10 | i >>> 22) + t << 0) ^ ((n = ((n += (t ^ (i | ~e)) + s[14] - 1416354905) << 15 | n >>> 17) + i << 0) | ~t)) + s[5] - 57434055) << 21 | e >>> 11) + n << 0, e = ((e += ((i = ((i += (e ^ ((t = ((t += (n ^ (e | ~i)) + s[12] + 1700485571) << 6 | t >>> 26) + e << 0) | ~n)) + s[3] - 1894986606) << 10 | i >>> 22) + t << 0) ^ ((n = ((n += (t ^ (i | ~e)) + s[10] - 1051523) << 15 | n >>> 17) + i << 0) | ~t)) + s[1] - 2054922799) << 21 | e >>> 11) + n << 0, e = ((e += ((i = ((i += (e ^ ((t = ((t += (n ^ (e | ~i)) + s[8] + 1873313359) << 6 | t >>> 26) + e << 0) | ~n)) + s[15] - 30611744) << 10 | i >>> 22) + t << 0) ^ ((n = ((n += (t ^ (i | ~e)) + s[6] - 1560198380) << 15 | n >>> 17) + i << 0) | ~t)) + s[13] + 1309151649) << 21 | e >>> 11) + n << 0, e = ((e += ((i = ((i += (e ^ ((t = ((t += (n ^ (e | ~i)) + s[4] - 145523070) << 6 | t >>> 26) + e << 0) | ~n)) + s[11] - 1120210379) << 10 | i >>> 22) + t << 0) ^ ((n = ((n += (t ^ (i | ~e)) + s[2] + 718787259) << 15 | n >>> 17) + i << 0) | ~t)) + s[9] - 343485551) << 21 | e >>> 11) + n << 0, this.first ? (this.h0 = t + 1732584193 << 0, this.h1 = e - 271733879 << 0, this.h2 = n - 1732584194 << 0, this.h3 = i + 271733878 << 0, this.first = !1) : (this.h0 = this.h0 + t << 0, this.h1 = this.h1 + e << 0, this.h2 = this.h2 + n << 0, this.h3 = this.h3 + i << 0)
- }
- t.prototype.hex = function() {
- this.finalize();
- var t = this.h0,
- e = this.h1,
- i = this.h2,
- r = this.h3;
- return n[t >> 4 & 15] + n[15 & t] + n[t >> 12 & 15] + n[t >> 8 & 15] + n[t >> 20 & 15] + n[t >> 16 & 15] + n[t >> 28 & 15] + n[t >> 24 & 15] + n[e >> 4 & 15] + n[15 & e] + n[e >> 12 & 15] + n[e >> 8 & 15] + n[e >> 20 & 15] + n[e >> 16 & 15] + n[e >> 28 & 15] + n[e >> 24 & 15] + n[i >> 4 & 15] + n[15 & i] + n[i >> 12 & 15] + n[i >> 8 & 15] + n[i >> 20 & 15] + n[i >> 16 & 15] + n[i >> 28 & 15] + n[i >> 24 & 15] + n[r >> 4 & 15] + n[15 & r] + n[r >> 12 & 15] + n[r >> 8 & 15] + n[r >> 20 & 15] + n[r >> 16 & 15] + n[r >> 28 & 15] + n[r >> 24 & 15]
- }
- t.prototype.finalize = function() {
- var u = [128, 32768, 8388608, -2147483648];
- if (!this.finalized) {
- this.finalized = !0;
- var t = this.blocks,
- e = this.lastByteIndex;
- t[e >> 2] |= u[3 & e], e >= 56 && (this.hashed || this.hash(), t[0] = t[16], t[16] = t[1] = t[2] = t[3] = t[4] = t[5] = t[6] = t[7] = t[8] = t[9] = t[10] = t[11] = t[12] = t[13] = t[14] = t[15] = 0), t[14] = this.bytes << 3, t[15] = this.hBytes << 3 | this.bytes >>> 29, this.hash()
- }
- }
复制代码 |
|