|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- var createOutputMethod = function(e) {
- return function(t) {
- return new Md5(!0).update(t)[e]()
- }
- },
- function Md5(e) {
- if (e) blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0,
- this.blocks = blocks,
- this.buffer8 = buffer8;
- else if (ARRAY_BUFFER) {
- var t = new ArrayBuffer(68);
- this.buffer8 = new Uint8Array(t),
- this.blocks = new Uint32Array(t)
- } 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
- }
- Md5.prototype.update = function(e) {
- if (!this.finalized) {
- var t, n = typeof e;
- if ("string" != n) {
- if ("object" != n) throw ERROR;
- if (null === e) throw ERROR;
- if (ARRAY_BUFFER && e.constructor === ArrayBuffer) e = new Uint8Array(e);
- else if (!(Array.isArray(e) || ARRAY_BUFFER && ArrayBuffer.isView(e))) throw ERROR;
- t = !0
- }
- for (var i, r, o = 0,
- s = e.length,
- a = this.blocks,
- l = this.buffer8; o < s;) {
- if (this.hashed && (this.hashed = !1, a[0] = a[16], a[16] = a[1] = a[2] = a[3] = a[4] = a[5] = a[6] = a[7] = a[8] = a[9] = a[10] = a[11] = a[12] = a[13] = a[14] = a[15] = 0), t) if (ARRAY_BUFFER) for (r = this.start; o < s && r < 64; ++o) l[r++] = e[o];
- else for (r = this.start; o < s && r < 64; ++o) a[r >> 2] |= e[o] << SHIFT[3 & r++];
- else if (ARRAY_BUFFER) for (r = this.start; o < s && r < 64; ++o)(i = e.charCodeAt(o)) < 128 ? l[r++] = i : (i < 2048 ? l[r++] = 192 | i >> 6 : (i < 55296 || 57344 <= i ? l[r++] = 224 | i >> 12 : (i = 65536 + ((1023 & i) << 10 | 1023 & e.charCodeAt(++o)), l[r++] = 240 | i >> 18, l[r++] = 128 | i >> 12 & 63), l[r++] = 128 | i >> 6 & 63), l[r++] = 128 | 63 & i);
- else for (r = this.start; o < s && r < 64; ++o)(i = e.charCodeAt(o)) < 128 ? a[r >> 2] |= i << SHIFT[3 & r++] : (i < 2048 ? a[r >> 2] |= (192 | i >> 6) << SHIFT[3 & r++] : (i < 55296 || 57344 <= i ? a[r >> 2] |= (224 | i >> 12) << SHIFT[3 & r++] : (i = 65536 + ((1023 & i) << 10 | 1023 & e.charCodeAt(++o)), a[r >> 2] |= (240 | i >> 18) << SHIFT[3 & r++], a[r >> 2] |= (128 | i >> 12 & 63) << SHIFT[3 & r++]), a[r >> 2] |= (128 | i >> 6 & 63) << SHIFT[3 & r++]), a[r >> 2] |= (128 | 63 & i) << SHIFT[3 & r++]);
- this.lastByteIndex = r,
- this.bytes += r - this.start,
- 64 <= r ? (this.start = r - 64, this.hash(), this.hashed = !0) : this.start = r
- }
- return 4294967295 < this.bytes && (this.hBytes += this.bytes / 4294967296 << 0, this.bytes = this.bytes % 4294967296),
- this
- }
- },
- Md5.prototype.finalize = function() {
- if (!this.finalized) {
- this.finalized = !0;
- var e = this.blocks,
- t = this.lastByteIndex;
- e[t >> 2] |= EXTRA[3 & t],
- 56 <= t && (this.hashed || this.hash(), e[0] = e[16], e[16] = e[1] = e[2] = e[3] = e[4] = e[5] = e[6] = e[7] = e[8] = e[9] = e[10] = e[11] = e[12] = e[13] = e[14] = e[15] = 0),
- e[14] = this.bytes << 3,
- e[15] = this.hBytes << 3 | this.bytes >>> 29,
- this.hash()
- }
- },
- Md5.prototype.hex = function() {
- this.finalize();
- var e = this.h0,
- t = this.h1,
- n = this.h2,
- i = this.h3;
- return HEX_CHARS[e >> 4 & 15] + HEX_CHARS[15 & e] + HEX_CHARS[e >> 12 & 15] + HEX_CHARS[e >> 8 & 15] + HEX_CHARS[e >> 20 & 15] + HEX_CHARS[e >> 16 & 15] + HEX_CHARS[e >> 28 & 15] + HEX_CHARS[e >> 24 & 15] + HEX_CHARS[t >> 4 & 15] + HEX_CHARS[15 & t] + HEX_CHARS[t >> 12 & 15] + HEX_CHARS[t >> 8 & 15] + HEX_CHARS[t >> 20 & 15] + HEX_CHARS[t >> 16 & 15] + HEX_CHARS[t >> 28 & 15] + HEX_CHARS[t >> 24 & 15] + HEX_CHARS[n >> 4 & 15] + HEX_CHARS[15 & n] + HEX_CHARS[n >> 12 & 15] + HEX_CHARS[n >> 8 & 15] + HEX_CHARS[n >> 20 & 15] + HEX_CHARS[n >> 16 & 15] + HEX_CHARS[n >> 28 & 15] + HEX_CHARS[n >> 24 & 15] + HEX_CHARS[i >> 4 & 15] + HEX_CHARS[15 & i] + HEX_CHARS[i >> 12 & 15] + HEX_CHARS[i >> 8 & 15] + HEX_CHARS[i >> 20 & 15] + HEX_CHARS[i >> 16 & 15] + HEX_CHARS[i >> 28 & 15] + HEX_CHARS[i >> 24 & 15]
- },
- Md5.prototype.toString = Md5.prototype.hex,
- Md5.prototype.digest = function() {
- this.finalize();
- var e = this.h0,
- t = this.h1,
- n = this.h2,
- i = this.h3;
- return [255 & e, e >> 8 & 255, e >> 16 & 255, e >> 24 & 255, 255 & t, t >> 8 & 255, t >> 16 & 255, t >> 24 & 255, 255 & n, n >> 8 & 255, n >> 16 & 255, n >> 24 & 255, 255 & i, i >> 8 & 255, i >> 16 & 255, i >> 24 & 255]
- },
- Md5.prototype.array = Md5.prototype.digest,
- Md5.prototype.arrayBuffer = function() {
- this.finalize();
- var e = new ArrayBuffer(16),
- t = new Uint32Array(e);
- return t[0] = this.h0,
- t[1] = this.h1,
- t[2] = this.h2,
- t[3] = this.h3,
- e
- },
- Md5.prototype.buffer = Md5.prototype.arrayBuffer,
- Md5.prototype.base64 = function() {
- for (var e, t, n, i = "",
- r = this.array(), o = 0; o < 15;) e = r[o++],
- t = r[o++],
- n = r[o++],
- i += BASE64_ENCODE_CHAR[e >>> 2] + BASE64_ENCODE_CHAR[63 & (e << 4 | t >>> 4)] + BASE64_ENCODE_CHAR[63 & (t << 2 | n >>> 6)] + BASE64_ENCODE_CHAR[63 & n];
- return e = r[o],
- i + (BASE64_ENCODE_CHAR[e >>> 2] + BASE64_ENCODE_CHAR[e << 4 & 63] + "==")
- };
- var exports = createMethod();
- COMMON_Js ? module.exports = exports : root.md5 = exports
- }()
- })),
- secret = "0b50b02fd0d73a9c4c8c3a781c30845f";
- function createSign(e) {
- if ("[object Object]" !== Object.prototype.toString.call(e)) throw new Error("The parameter of query must be a Object.");
- var t = Math.floor(Date.now() / 1e3);
- Object.assign(e, {
- timestamp: t
- });
- var n = Object.keys(e);
- n.sort();
- for (var i = "",
- r = 0; r < n.length; r++) {
- var o = n[r];
- i += (0 == r ? "" : "&") + o + "=" + e[o]
- }
- return {
- sign: md5(i += secret),
- timestamp: t,
- md5: md5
- }
- }
复制代码
上面是我从千千音乐中搜索sign,在sign: md5(i += secret)下的断点,然后从里头拿出来的一些相关函数,最后传入一个对象到createSign中,返回给我一个对象,由于js不太熟,我想要的是字符串,而且sign真正的加密是通过这个new Md5(!0).update(t)[e]()方法得出来的,我脑壳疼,有没有大佬指点一下 (由于字数要求,我删了一点代码,希望大佬能动手帮忙调试一下) |
|