From b7be0d0902b092ff1b7e57e7fc819150e85cfd16 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 4 Aug 2022 01:07:39 +0100 Subject: chat --- md5.lua | 167 ---------------------------------------------------------------- 1 file changed, 167 deletions(-) delete mode 100644 md5.lua (limited to 'md5.lua') diff --git a/md5.lua b/md5.lua deleted file mode 100644 index b421587..0000000 --- a/md5.lua +++ /dev/null @@ -1,167 +0,0 @@ --- from https://github.com/philanc/plc/blob/master/plc/md5.lua ------------------------------------------------------------------------- --- md5 hash - see RFC 1321 - https://www.ietf.org/rfc/rfc1321.txt - -local spack, sunpack = string.pack, string.unpack - ------------------------------------------------------------------------- - -local function FF(a, b, c, d, x, s, ac) - a = (a + ((b & c) | ((~b) & d)) + x + ac) & 0xffffffff - a = ((a << s) | (a >> (32-s))) & 0xffffffff - a = (a + b) & 0xffffffff - return a -end - -local function GG(a, b, c, d, x, s, ac) - a = (a + ((b & d) | c & (~d) ) + x + ac) & 0xffffffff - a = ((a << s) | (a >> (32-s))) & 0xffffffff - a = (a + b) & 0xffffffff - return a -end - -local function HH(a, b, c, d, x, s, ac) - a = (a + ((b ~ c ~ d)) + x + ac) & 0xffffffff - a = ((a << s) | (a >> (32-s))) & 0xffffffff - a = (a + b) & 0xffffffff - return a -end - -local function II(a, b, c, d, x, s, ac) - a = (a + (c ~ (b | ~d)) + x + ac) & 0xffffffff - a = ((a << s) | (a >> (32-s))) & 0xffffffff - a = (a + b) & 0xffffffff - return a -end - -local function transform(state, input, i, t) - -- process the 64-byte input block in string 'input' at offset 'i' - -- t is a uint32[16] array. It is passed as a parameter - -- for performance reasons - -- - local a, b, c, d = state[1], state[2], state[3], state[4] - - -- load array - for j = 1, 16 do - t[j] = sunpack("= 64 do - -- process block - transform(state, input, i, ibt) - i = i + 64 -- update input index - r = r - 64 -- update number of unprocessed bytes - end - -- finalize. must append to input a mandatory 0x80 byte, some - -- padding, and the input bit-length ('inputbits') - local lastblock -- the rest of input .. some padding .. inputbits - local padlen -- padding length in bytes - if r < 56 then padlen = 55 - r else padlen = 119 - r end - lastblock = input:sub(i) -- remaining input - .. '\x80' .. ('\0'):rep(padlen) --padding - .. spack("