在Javascript中解密字符串

时间:2015-05-22 09:10:59

标签: javascript encryption hash md5 hmac

我正在尝试使用开发人员用来解密它的代码来解密这些字符串WUUVJPVUVJS^J_TJ^RSPVT^SWV^TW^TJQ^VVJSRUJ_TWJ^R^UWU

/** ========== \resources\md5.js ========== **/
var CryptoJS = CryptoJS || function(w, i) {
var f = {},
    e = f.lib = {},
    h = function() {},
    o = e.Base = {
        extend: function(a) {
            h.prototype = this;
            var g = new h;
            a && g.mixIn(a);
            g.hasOwnProperty("init") || (g.init = function() {
                g.$super.init.apply(this, arguments);
            });
            g.init.prototype = g;
            g.$super = this;
            return g;
        },
        create: function() {
            var a = this.extend();
            a.init.apply(a, arguments);
            return a;
        },
        init: function() {},
        mixIn: function(a) {
            for (var g in a) {
                a.hasOwnProperty(g) && (this[g] = a[g]);
            }
            a.hasOwnProperty("toString") && (this.toString = a.toString);
        },
        clone: function() {
            return this.init.prototype.extend(this);
        }
    },
    j = e.WordArray = o.extend({
        init: function(a, g) {
            a = this.words = a || [];
            this.sigBytes = g != i ? g : 4 * a.length;
        },
        toString: function(a) {
            return (a || x).stringify(this);
        },
        concat: function(l) {
            var n = this.words,
                k = l.words,
                p = this.sigBytes;
            l = l.sigBytes;
            this.clamp();
            if (p % 4) {
                for (var m = 0; m < l; m++) {
                    n[p + m >>> 2] |= (k[m >>> 2] >>> 24 - 8 * (m % 4) & 255)   << 24 - 8 * ((p + m) % 4);
                }
            } else {
                if (65535 < k.length) {
                    for (m = 0; m < l; m += 4) {
                        n[p + m >>> 2] = k[m >>> 2];
                    }
                } else {
                    n.push.apply(n, k);
                }
            }
            this.sigBytes += l;
            return this;
        },
          clamp: function() {
            var a = this.words,
                g = this.sigBytes;
            a[g >>> 2] &= 4294967295 << 32 - 8 * (g % 4);
            a.length = w.ceil(g / 4);
        },
        clone: function() {
            var a = o.clone.call(this);
            a.words = this.words.slice(0);
            return a;
        },
        random: function(k) {
            for (var l = [], g = 0; g < k; g += 4) {
                l.push(4294967296 * w.random() | 0);
            }
            return new j.init(l, k);
        }
    }),
    z = f.enc = {},
    x = z.Hex = {
        stringify: function(m) {
            var l = m.words;
            m = m.sigBytes;
            for (var n = [], p = 0; p < m; p++) {
                var q = l[p >>> 2] >>> 24 - 8 * (p % 4) & 255;
                n.push((q >>> 4).toString(16));
                n.push((q & 15).toString(16));
            }
            return n.join("");
        },
        parse: function(l) {
            for (var k = l.length, m = [], n = 0; n < k; n += 2) {
                m[n >>> 3] |= parseInt(l.substr(n, 2), 16) << 24 - 4 * (n %  8);
            }
            return new j.init(m, k / 2);
        }
    },
    b = z.Latin1 = {
        stringify: function(l) {
            var k = l.words;
            l = l.sigBytes;
            for (var m = [], n = 0; n < l; n++) {
                m.push(String.fromCharCode(k[n >>> 2] >>> 24 - 8 * (n % 4) & 255));
            }
            return m.join("");
        },
        parse: function(l) {
            for (var k = l.length, m = [], n = 0; n < k; n++) {
                m[n >>> 2] |= (l.charCodeAt(n) & 255) << 24 - 8 * (n % 4);
            }
            return new j.init(m, k);
        }
    },
    y = z.Utf8 = {
        stringify: function(a) {
            try {
                return decodeURIComponent(escape(b.stringify(a)));
            } catch (k) {
                throw Error("Malformed UTF-8 data");
            }
        },
        parse: function(a) {
            return b.parse(unescape(encodeURIComponent(a)));
        }
    },
    c = e.BufferedBlockAlgorithm = o.extend({
        reset: function() {
            this._data = new j.init;
            this._nDataBytes = 0;
        },
        _append: function(a) {
            "string" == typeof a && (a = y.parse(a));
            this._data.concat(a);
            this._nDataBytes += a.sigBytes;
        },
        _process: function(p) {
            var n = this._data,
                q = n.words,
                r = n.sigBytes,
                s = this.blockSize,
                u = r / (4 * s),
                u = p ? w.ceil(u) : w.max((u | 0) - this._minBufferSize, 0);
            p = u * s;
            r = w.min(4 * p, r);
            if (p) {
                for (var t = 0; t < p; t += s) {
                    this._doProcessBlock(q, t);
                }
                t = q.splice(0, p);
                n.sigBytes -= r;
            }
            return new j.init(t, r);
        },
        clone: function() {
            var a = o.clone.call(this);
            a._data = this._data.clone();
            return a;
        },
        _minBufferSize: 0
    });
e.Hasher = c.extend({
    cfg: o.extend(),
    init: function(a) {
        this.cfg = this.cfg.extend(a);
        this.reset();
    },
    reset: function() {
        c.reset.call(this);
        this._doReset();
    },
    update: function(a) {
        this._append(a);
        this._process();
        return this;
    },
    finalize: function(a) {
        a && this._append(a);
        return this._doFinalize();
    },
    blockSize: 16,
    _createHelper: function(a) {
        return function(k, l) {
            return (new a.init(l)).finalize(k);
        };
    },
    _createHmacHelper: function(a) {
        return function(k, l) {
            return (new d.HMAC.init(a, l)).finalize(k);
        };
    }
});
var d = f.algo = {};
return f;
  }(Math);
  (function(i) {
  function f(n, s, p, q, t, r, u) {
    n = n + (s & p | ~s & q) + t + u;
    return (n << r | n >>> 32 - r) + s;
}

function d(n, s, p, q, t, r, u) {
    n = n + (s & q | p & ~q) + t + u;
    return (n << r | n >>> 32 - r) + s;
}

function c(n, s, p, q, t, r, u) {
    n = n + (s ^ p ^ q) + t + u;
    return (n << r | n >>> 32 - r) + s;
}

function e(n, s, p, q, t, r, u) {
    n = n + (p ^ (s | ~q)) + t + u;
    return (n << r | n >>> 32 - r) + s;
}
for (var h = CryptoJS, g = h.lib, o = g.WordArray, j = g.Hasher, g = h.algo, b = [], k = 0; 64 > k; k++) {
    b[k] = 4294967296 * i.abs(i.sin(k + 1)) | 0;
}
g = g.MD5 = j.extend({
    _doReset: function() {
        this._hash = new o.init([1732584193, 4023233417, 2562383102, 271733878]);
    },
    _doProcessBlock: function(I, L) {
        for (var l = 0; 16 > l; l++) {
            var J = L + l,
                S = I[J];
            I[J] = (S << 8 | S >>> 24) & 16711935 | (S << 24 | S >>> 8) & 4278255360;
        }
        var l = this._hash.words,
            J = I[L + 0],
            S = I[L + 1],
            K = I[L + 2],
            M = I[L + 3],
            N = I[L + 4],
            O = I[L + 5],
            P = I[L + 6],
            Q = I[L + 7],
            R = I[L + 8],
            T = I[L + 9],
            U = I[L + 10],
            V = I[L + 11],
            a = I[L + 12],
            m = I[L + 13],
            p = I[L + 14],
            F = I[L + 15],
            n = l[0],
            E = l[1],
            G = l[2],
            H = l[3],
            n = f(n, E, G, H, J, 7, b[0]),
            H = f(H, n, E, G, S, 12, b[1]),
            G = f(G, H, n, E, K, 17, b[2]),
            E = f(E, G, H, n, M, 22, b[3]),
            n = f(n, E, G, H, N, 7, b[4]),
            H = f(H, n, E, G, O, 12, b[5]),
            G = f(G, H, n, E, P, 17, b[6]),
            E = f(E, G, H, n, Q, 22, b[7]),
            n = f(n, E, G, H, R, 7, b[8]),
            H = f(H, n, E, G, T, 12, b[9]),
            G = f(G, H, n, E, U, 17, b[10]),
            E = f(E, G, H, n, V, 22, b[11]),
            n = f(n, E, G, H, a, 7, b[12]),
            H = f(H, n, E, G, m, 12, b[13]),
            G = f(G, H, n, E, p, 17, b[14]),
            E = f(E, G, H, n, F, 22, b[15]),
            n = d(n, E, G, H, S, 5, b[16]),
            H = d(H, n, E, G, P, 9, b[17]),
            G = d(G, H, n, E, V, 14, b[18]),
            E = d(E, G, H, n, J, 20, b[19]),
            n = d(n, E, G, H, O, 5, b[20]),
            H = d(H, n, E, G, U, 9, b[21]),
            G = d(G, H, n, E, F, 14, b[22]),
            E = d(E, G, H, n, N, 20, b[23]),
            n = d(n, E, G, H, T, 5, b[24]),
            H = d(H, n, E, G, p, 9, b[25]),
            G = d(G, H, n, E, M, 14, b[26]),
            E = d(E, G, H, n, R, 20, b[27]),
            n = d(n, E, G, H, m, 5, b[28]),
            H = d(H, n, E, G, K, 9, b[29]),
            G = d(G, H, n, E, Q, 14, b[30]),
            E = d(E, G, H, n, a, 20, b[31]),
            n = c(n, E, G, H, O, 4, b[32]),
            H = c(H, n, E, G, R, 11, b[33]),
            G = c(G, H, n, E, V, 16, b[34]),
            E = c(E, G, H, n, p, 23, b[35]),
            n = c(n, E, G, H, S, 4, b[36]),
            H = c(H, n, E, G, N, 11, b[37]),
            G = c(G, H, n, E, Q, 16, b[38]),
            E = c(E, G, H, n, U, 23, b[39]),
            n = c(n, E, G, H, m, 4, b[40]),
            H = c(H, n, E, G, J, 11, b[41]),
            G = c(G, H, n, E, M, 16, b[42]),
            E = c(E, G, H, n, P, 23, b[43]),
            n = c(n, E, G, H, T, 4, b[44]),
            H = c(H, n, E, G, a, 11, b[45]),
            G = c(G, H, n, E, F, 16, b[46]),
            E = c(E, G, H, n, K, 23, b[47]),
            n = e(n, E, G, H, J, 6, b[48]),
            H = e(H, n, E, G, Q, 10, b[49]),
            G = e(G, H, n, E, p, 15, b[50]),
            E = e(E, G, H, n, O, 21, b[51]),
            n = e(n, E, G, H, a, 6, b[52]),
            H = e(H, n, E, G, M, 10, b[53]),
            G = e(G, H, n, E, U, 15, b[54]),
            E = e(E, G, H, n, S, 21, b[55]),
            n = e(n, E, G, H, R, 6, b[56]),
            H = e(H, n, E, G, F, 10, b[57]),
            G = e(G, H, n, E, P, 15, b[58]),
            E = e(E, G, H, n, m, 21, b[59]),
            n = e(n, E, G, H, N, 6, b[60]),
            H = e(H, n, E, G, V, 10, b[61]),
            G = e(G, H, n, E, K, 15, b[62]),
            E = e(E, G, H, n, T, 21, b[63]);
        l[0] = l[0] + n | 0;
        l[1] = l[1] + E | 0;
        l[2] = l[2] + G | 0;
        l[3] = l[3] + H | 0;
    },
    _doFinalize: function() {
        var m = this._data,
            q = m.words,
            n = 8 * this._nDataBytes,
            p = 8 * m.sigBytes;
        q[p >>> 5] |= 128 << 24 - p % 32;
        var r = i.floor(n / 4294967296);
        q[(p + 64 >>> 9 << 4) + 15] = (r << 8 | r >>> 24) & 16711935 | (r << 24 | r >>> 8) & 4278255360;
        q[(p + 64 >>> 9 << 4) + 14] = (n << 8 | n >>> 24) & 16711935 | (n <<    24 | n >>> 8) & 4278255360;
        m.sigBytes = 4 * (q.length + 1);
        this._process();
        m = this._hash;
        q = m.words;
        for (n = 0; 4 > n; n++) {
            p = q[n], q[n] = (p << 8 | p >>> 24) & 16711935 | (p << 24 | p         >>> 8) & 4278255360;
        }
        return m;
    },
    clone: function() {
        var l = j.clone.call(this);
        l._hash = this._hash.clone();
        return l;
    }
});
h.MD5 = j._createHelper(g);
h.HmacMD5 = j._createHmacHelper(g);
})(Math);

我读加密时间超过4小时但没有成功解密这些字符串 我是初学者使用Java脚本,如何使用此代码解密上面的文本 感谢

1 个答案:

答案 0 :(得分:1)

HMAC无法解密&#34;。像哈希函数一样,HMAC是一个不能被反转的函数。 HMAC功能和散列函数之间的唯一区别是第一个涉及&#34;秘密&#34;第二个有公共定义。

如果您打算使用CryptoJS,请使用AES(hmac / hash和cipher之间的主要区别在于第二个可以反转)