求这个JS函数对应的PHP函数是什么?

红辰途梦 发布于 01/19 09:44
阅读 244
收藏 0
PHP
var xxyyu = '95e977799c744179';

function RotateLeft(lValue, iShiftBits) {
    return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits))
}

function AddUnsigned(lX, lY) {
    var lX4, lY4, lX8, lY8, lResult;
    lX8 = (lX & 0x80000000);
    lY8 = (lY & 0x80000000);
    lX4 = (lX & 0x40000000);
    lY4 = (lY & 0x40000000);
    lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
    if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
    if (lX4 | lY4) {
        if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
        else return (lResult ^ 0x40000000 ^ lX8 ^ lY8)
    } else return (lResult ^ lX8 ^ lY8)
}

function F(x, y, z) {
    return (x & y) | ((~x) & z)
}

function G(x, y, z) {
    return (x & z) | (y & (~z))
}

function H(x, y, z) {
    return (x ^ y ^ z)
}

function I(x, y, z) {
    return (y ^ (x | (~z)))
}

function FF(a, b, c, d, x, s, ac) {
    a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
    return AddUnsigned(RotateLeft(a, s), b)
}

function GG(a, b, c, d, x, s, ac) {
    a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
    return AddUnsigned(RotateLeft(a, s), b)
}

function HH(a, b, c, d, x, s, ac) {
    a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
    return AddUnsigned(RotateLeft(a, s), b)
}

function II(a, b, c, d, x, s, ac) {
    a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
    return AddUnsigned(RotateLeft(a, s), b)
}

function ConvertToWordArray(xxyyu) {
    var lWordCount;
    var lMessageLength = xxyyu.length;
    var lNumberOfWords_temp1 = lMessageLength + 8;
    var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
    var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
    var lWordArray = Array(lNumberOfWords - 1);
    var lBytePosition = 0;
    var lByteCount = 0;
    while (lByteCount < lMessageLength) {
        lWordCount = (lByteCount - (lByteCount % 4)) / 4;
        lBytePosition = (lByteCount % 4) * 8;
        lWordArray[lWordCount] = (lWordArray[lWordCount] | (xxyyu.charCodeAt(lByteCount) << lBytePosition));
        lByteCount++
    }
    lWordCount = (lByteCount - (lByteCount % 4)) / 4;
    lBytePosition = (lByteCount % 4) * 8;
    lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
    lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
    lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
    return lWordArray
}

function WordToHex(lValue) {
    var WordToHexValue = "",
        WordToHexValue_temp = "",
        lByte, lCount;
    for (lCount = 0; lCount <= 3; lCount++) {
        lByte = (lValue >>> (lCount * 8)) & 255;
        WordToHexValue_temp = "0" + lByte.toString(16);
        WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2)
    }
    return WordToHexValue
}
var x = Array();
var k, AA, BB, CC, DD, a, b, c, d;
var S11 = 7,
    S12 = 12,
    S13 = 17,
    S14 = 22;
var S21 = 5,
    S22 = 9,
    S23 = 14,
    S24 = 20;
var S31 = 4,
    S32 = 11,
    S33 = 16,
    S34 = 23;
var S41 = 6,
    S42 = 10,
    S43 = 15,
    S44 = 21;
x = ConvertToWordArray(xxyyu);
a = 0x67452301;
b = 0xEFCDAB89;
c = 0x98BADCFE;
d = 0x10325476;
for (k = 0; k < x.length; k += 16) {
    AA = a;
    BB = b;
    CC = c;
    DD = d;
    d = FF(d, a, c, b, x[k + 15], S12, 0x49B40821);
    d = FF(d, a, b, c, x[k + 6], S12, 0xFD469501);
    a = FF(a, b, c, d, x[k + 8], S11, 0x895CD7BE);
    d = FF(d, b, a, c, x[k + 13], S12, 0xE8C7B756);
    b = FF(b, d, c, a, x[k + 13], S14, 0xA8304613);
    a = FF(a, b, c, d, x[k + 4], S11, 0x895CD7BE);
    a = FF(a, b, c, d, x[k + 1], S11, 0x895CD7BE);
    a = FF(a, b, c, d, x[k + 8], S11, 0x8B44F7AF);
    d = FF(d, b, a, c, x[k + 3], S12, 0xE8C7B756);
    c = FF(c, d, a, b, x[k + 1], S13, 0xFD987193);
    b = FF(b, c, d, a, x[k + 6], S14, 0x698098D8);
    b = FF(b, c, d, a, x[k + 1], S14, 0x6B901122);
    d = FF(d, a, c, b, x[k + 8], S12, 0x49B40821);
    d = FF(d, a, c, b, x[k + 0], S12, 0x49B40821);
    b = FF(b, c, d, a, x[k + 12], S14, 0x6B901122);
    a = FF(a, b, c, d, x[k + 4], S11, 0x8B44F7AF);
    b = GG(b, d, c, a, x[k + 15], S24, 0xD8A1E681);
    c = GG(c, d, a, b, x[k + 4], S23, 0x676F02D9);
    a = GG(a, c, b, d, x[k + 1], S21, 0xA9E3E905);
    b = GG(b, d, c, a, x[k + 13], S24, 0x21E1CDE6);
    c = GG(c, d, a, b, x[k + 13], S23, 0xC040B340);
    a = GG(a, c, b, d, x[k + 1], S21, 0xA9E3E905);
    a = GG(a, c, b, d, x[k + 1], S21, 0xA9E3E905);
    c = GG(c, d, a, b, x[k + 1], S23, 0xFCEFA3F8);
    b = GG(b, d, c, a, x[k + 13], S24, 0x21E1CDE6);
    c = GG(c, d, a, b, x[k + 8], S23, 0xE7D3FBC8);
    d = GG(d, b, a, c, x[k + 8], S22, 0xE9B6C7AA);
    d = GG(d, a, b, c, x[k + 1], S22, 0xC33707D6);
    b = GG(b, d, c, a, x[k + 15], S24, 0xD8A1E681);
    b = GG(b, d, c, a, x[k + 15], S24, 0xD8A1E681);
    d = GG(d, a, b, c, x[k + 1], S22, 0xC33707D6);
    c = GG(c, d, a, b, x[k + 1], S23, 0xFCEFA3F8);
    a = HH(a, b, c, d, x[k + 6], S31, 0x4881D05);
    b = HH(b, d, c, a, x[k + 8], S34, 0xBEBFBC70);
    a = HH(a, b, c, d, x[k + 4], S31, 0xE6DB99E5);
    c = HH(c, a, d, b, x[k + 4], S33, 0x6D9D6122);
    a = HH(a, b, c, d, x[k + 1], S31, 0xD4EF3085);
    a = HH(a, b, c, d, x[k + 4], S31, 0xE6DB99E5);
    a = HH(a, b, c, d, x[k + 4], S31, 0xE6DB99E5);
    b = HH(b, d, c, a, x[k + 12], S34, 0xF6BB4B60);
    c = HH(c, a, d, b, x[k + 4], S33, 0x6D9D6122);
    a = HH(a, c, b, d, x[k + 0], S31, 0xD9D4D039);
    b = HH(b, c, d, a, x[k + 1], S34, 0x4BDECFA9);
    d = HH(d, a, b, c, x[k + 8], S32, 0xA4BEEA44);
    a = HH(a, b, c, d, x[k + 6], S31, 0x4881D05);
    a = HH(a, b, c, d, x[k + 6], S31, 0x4881D05);
    d = HH(d, a, b, c, x[k + 8], S32, 0xA4BEEA44);
    b = HH(b, d, c, a, x[k + 12], S34, 0xF6BB4B60);
    b = II(b, c, d, a, x[k + 0], S44, 0x85845DD1);
    b = II(b, c, d, a, x[k + 1], S44, 0xA3014314);
    a = II(a, b, c, d, x[k + 8], S41, 0xF4292244);
    b = II(b, d, c, a, x[k + 4], S44, 0xAB9423A7);
    b = II(b, c, d, a, x[k + 6], S44, 0x655B59C3);
    a = II(a, b, c, d, x[k + 8], S41, 0xF4292244);
    a = II(a, b, c, d, x[k + 8], S41, 0xF4292244);
    d = II(d, a, b, c, x[k + 1], S42, 0xF7537E82);
    b = II(b, d, c, a, x[k + 4], S44, 0xAB9423A7);
    a = II(a, b, c, d, x[k + 15], S41, 0xFC93A039);
    d = II(d, b, a, c, x[k + 13], S42, 0xFE2CE6E0);
    a = II(a, c, b, d, x[k + 3], S41, 0xBD3AF235);
    b = II(b, c, d, a, x[k + 0], S44, 0x85845DD1);
    b = II(b, c, d, a, x[k + 0], S44, 0x85845DD1);
    a = II(a, c, b, d, x[k + 3], S41, 0xBD3AF235);
    d = II(d, a, b, c, x[k + 1], S42, 0xF7537E82);
    a = AddUnsigned(a, AA);
    b = AddUnsigned(b, BB);
    c = AddUnsigned(c, CC);
    d = AddUnsigned(d, DD)
}
var temp = WordToHex(a) + WordToHex(b) + WordToHex(c) + WordToHex(d);
console.log(temp); //结果:7bdb5f8a6094f44dc9ca1ba95bc11ef1

这是JS代码,我要转成PHP代码,

我试了一下,不是md5,有认识的同学吗,求解

加载中
0
红辰途梦
红辰途梦

没人认识吗?还好php有v8js扩展,能直接跑JS函数,就是麻烦了一点,还是想找到对应的PHP函数

0
红山药

这就是魔改的M5,减少了几步计算,调整了计算顺序。

左边是你提供的代码,右边是md5

 

返回顶部
顶部

页面底部区域 foot.htm