Pedro Gimeno 51febea6c3 Implement incremental MD5
Two new functions:

md5.new(): returns a new MD5 state object with two methods:
 - MD5State:update(s) - adds the string s to the calculation
 - MD5State:finish()  - returns the final MD5 as a binary string

md5.tohex(): converts to hexadecimal the binary string returned by md5.sum() and MD5State:finish()
2016-07-02 21:31:54 +02:00
2015-04-06 21:13:45 +02:00
2016-07-02 20:26:40 +02:00
2016-07-02 21:31:54 +02:00
2015-02-09 13:07:59 +01:00

md5.lua Build Status

This pure-Lua module computes md5 in Lua 5.1, Lua 5.2 and LuaJIT, using native bit-manipulation libraries when available, and falling back to table-based manipulation of integers in 5.1.

It implements md5.sum and md5.sumhex like the kernel project md5 package, but it's done completely in Lua, with no dependencies on other libs or C files.

Usage

local md5 = require 'md5'

local md5_as_hex   = md5.sumhexa(message)   -- returns a hex string
local md5_as_data  = md5.sum(message)     -- returns raw bytes

Credits

This is a cleanup of an implementation by Adam Baldwin - https://gist.github.com/evilpacket/3647908

Which in turn was a mix of the bitwise lib, http://luaforge.net/projects/bit/ by hanzhao (abrash_han - at - hotmail.com), and http://equi4.com/md5/md5calc.lua, by Equi 4 Software.

Lua 5.2 and LuaJIT compatibility by Positive07

License

This library, as well as all the previous ones in which is based, is released under the MIT license (See license file for details).

Specs

The specs for this library are implemented with busted. In order to run them, install busted and then:

cd path/to/where/the/spec/folder/is
busted
Languages
Lua 100%