ZNZNCOOP

md5

Aug 29th, 2014
292
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.    *Apokalypsys, Dimus
  3.    *http://minecrafting.ru/
  4.    *http://minecrafting.ru/forum/viewtopic.php?f=32&t=5331
  5. ]]
  6.  
  7. local hex_char = "0123456789abcdef"
  8.  
  9. local function getHex(seed)
  10.    local str = ""
  11.    for i = 0, 3 do
  12.       local ind1, ind2 = bit.band(bit.brshift(seed, i * 8 + 4), 15) + 1, bit.band(bit.brshift(seed, i * 8), 15) + 1
  13.       str = str..
  14.       hex_char:sub(ind1, ind1)..
  15.       hex_char:sub(ind2, ind2)
  16.    end
  17.    return str
  18. end
  19.  
  20. local function string_to_blks(str)
  21.    local nblk = bit.brshift((str:len() + 8), 6) + 1
  22.    local blks = {}
  23.    local len = str:len()
  24.    for i = 0, nblk * 16 - 1 do
  25.       blks[i] = 0
  26.    end
  27.    for i = 0, str:len() - 1 do
  28.       blks[bit.brshift(i, 2)] =
  29.       bit.bor(
  30.          blks[bit.brshift(i, 2)],
  31.          bit.blshift(
  32.             str:byte(i+1),
  33.              (((i) % 4) * 8)
  34.           )
  35.       )
  36.    end
  37.       blks[bit.brshift(len, 2)] =
  38.       bit.bor(
  39.          blks[bit.brshift(len, 2)],
  40.          bit.blshift(
  41.             128,
  42.             (((len) % 4) * 8)
  43.          )
  44.       )
  45.       blks[nblk * 16 - 2] = len * 8
  46.    return blks
  47. end
  48.  
  49. local function add(x, y)
  50.    return x + y > 4294967296 and x + y or x + y - 4294967296
  51. end
  52.  
  53. local function rol(number, count)
  54.    return bit.bor(bit.blshift(number, count), bit.blogic_rshift(number, (32 - count)))
  55. end
  56.  
  57. local function X(a, b, c, x, s, t)
  58.    return add(rol(add(add(b, a), add(x, t)), s), c)
  59. end
  60.  
  61. local function F(a, b, c, d, x, s, t)
  62.    return X(bit.bor(bit.band(b, c), bit.band(bit.bnot(b), d)), a, b, x, s, t)
  63. end
  64.  
  65. local function G(a, b, c, d, x, s, t)
  66.    return X(bit.bor(bit.band(b, d), bit.band(c, bit.bnot(d))), a, b, x, s, t)
  67. end
  68.  
  69. local function H(a, b, c, d, x, s, t)
  70.    return X(bit.bxor(bit.bxor(b, c), d), a, b, x, s, t)
  71. end
  72.  
  73. local function I(a, b, c, d, x, s, t)
  74.    return X(bit.bxor(c, bit.bor(b, bit.bnot(d))), a, b, x, s, t)
  75. end
  76.  
  77. function md5(encoding_string)
  78.    local blks = string_to_blks(encoding_string)
  79.  
  80.    local a = 1732584193
  81.    local b = -271733879
  82.    local c = -1732584194
  83.    local d = 271733878
  84.  
  85.    for i = 0, #blks-1, 16 do
  86.       local olda, oldb, oldc, oldd = a, b, c, d
  87.  
  88.       a = F(a, b, c, d, blks[i+ 0], 7, -680876936)
  89.       d = F(d, a, b, c, blks[i+ 1], 12, -389564586)
  90.       c = F(c, d, a, b, blks[i+ 2], 17, 606105819)
  91.       b = F(b, c, d, a, blks[i+ 3], 22, -1044525330)
  92.       a = F(a, b, c, d, blks[i+ 4], 7, -176418897)
  93.       d = F(d, a, b, c, blks[i+ 5], 12, 1200080426)
  94.       c = F(c, d, a, b, blks[i+ 6], 17, -1473231341)
  95.       b = F(b, c, d, a, blks[i+ 7], 22, -45705983)
  96.       a = F(a, b, c, d, blks[i+ 8], 7, 1770035416)
  97.       d = F(d, a, b, c, blks[i+ 9], 12, -1958414417)
  98.       c = F(c, d, a, b, blks[i+10], 17, -42063)
  99.       b = F(b, c, d, a, blks[i+11], 22, -1990404162)
  100.       a = F(a, b, c, d, blks[i+12], 7, 1804603682)
  101.       d = F(d, a, b, c, blks[i+13], 12, -40341101)
  102.       c = F(c, d, a, b, blks[i+14], 17, -1502002290)
  103.       b = F(b, c, d, a, blks[i+15], 22, 1236535329)
  104.  
  105.       a = G(a, b, c, d, blks[i+ 1], 5, -165796510)
  106.       d = G(d, a, b, c, blks[i+ 6], 9, -1069501632)
  107.       c = G(c, d, a, b, blks[i+11], 14, 643717713)
  108.       b = G(b, c, d, a, blks[i+ 0], 20, -373897302)
  109.       a = G(a, b, c, d, blks[i+ 5], 5, -701558691)
  110.       d = G(d, a, b, c, blks[i+10], 9, 38016083)
  111.       c = G(c, d, a, b, blks[i+15], 14, -660478335)
  112.       b = G(b, c, d, a, blks[i+ 4], 20, -405537848)
  113.       a = G(a, b, c, d, blks[i+ 9], 5, 568446438)
  114.       d = G(d, a, b, c, blks[i+14], 9, -1019803690)
  115.       c = G(c, d, a, b, blks[i+ 3], 14, -187363961)
  116.       b = G(b, c, d, a, blks[i+ 8], 20, 1163531501)
  117.       a = G(a, b, c, d, blks[i+13], 5, -1444681467)
  118.       d = G(d, a, b, c, blks[i+ 2], 9, -51403784)
  119.       c = G(c, d, a, b, blks[i+ 7], 14, 1735328473)
  120.       b = G(b, c, d, a, blks[i+12], 20, -1926607734)
  121.  
  122.       a = H(a, b, c, d, blks[i+ 5], 4, -378558)
  123.       d = H(d, a, b, c, blks[i+ 8], 11, -2022574463)
  124.       c = H(c, d, a, b, blks[i+11], 16, 1839030562)
  125.       b = H(b, c, d, a, blks[i+14], 23, -35309556)
  126.       a = H(a, b, c, d, blks[i+ 1], 4, -1530992060)
  127.       d = H(d, a, b, c, blks[i+ 4], 11, 1272893353)
  128.       c = H(c, d, a, b, blks[i+ 7], 16, -155497632)
  129.       b = H(b, c, d, a, blks[i+10], 23, -1094730640)
  130.       a = H(a, b, c, d, blks[i+13], 4, 681279174)
  131.       d = H(d, a, b, c, blks[i+ 0], 11, -358537222)
  132.       c = H(c, d, a, b, blks[i+ 3], 16, -722521979)
  133.       b = H(b, c, d, a, blks[i+ 6], 23, 76029189)
  134.       a = H(a, b, c, d, blks[i+ 9], 4, -640364487)
  135.       d = H(d, a, b, c, blks[i+12], 11, -421815835)
  136.       c = H(c, d, a, b, blks[i+15], 16, 530742520)
  137.       b = H(b, c, d, a, blks[i+ 2], 23, -995338651)
  138.  
  139.       a = I(a, b, c, d, blks[i+ 0], 6, -198630844)
  140.       d = I(d, a, b, c, blks[i+ 7], 10, 1126891415)
  141.       c = I(c, d, a, b, blks[i+14], 15, -1416354905)
  142.       b = I(b, c, d, a, blks[i+ 5], 21, -57434055)
  143.       a = I(a, b, c, d, blks[i+12], 6, 1700485571)
  144.       d = I(d, a, b, c, blks[i+ 3], 10, -1894986606)
  145.       c = I(c, d, a, b, blks[i+10], 15, -1051523)
  146.       b = I(b, c, d, a, blks[i+ 1], 21, -2054922799)
  147.       a = I(a, b, c, d, blks[i+ 8], 6, 1873313359)
  148.       d = I(d, a, b, c, blks[i+15], 10, -30611744)
  149.       c = I(c, d, a, b, blks[i+ 6], 15, -1560198380)
  150.       b = I(b, c, d, a, blks[i+13], 21, 1309151649)
  151.       a = I(a, b, c, d, blks[i+ 4], 6, -145523070)
  152.       d = I(d, a, b, c, blks[i+11], 10, -1120210379)
  153.       c = I(c, d, a, b, blks[i+ 2], 15, 718787259)
  154.       b = I(b, c, d, a, blks[i+ 9], 21, -343485551)
  155.  
  156.       a = add(a, olda)
  157.       b = add(b, oldb)
  158.       c = add(c, oldc)
  159.       d = add(d, oldd)
  160.    end
  161.    return getHex(a)..getHex(b)..getHex(c)..getHex(d)
  162. end
RAW Paste Data