lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi list,

I have improved a md5 module for Lua, this is based on the lua-md5
module from keplerproject[1]. I have made these improve:

* merge sumhexa into binary, now a simple binary module for lua can
support all md5 functional, needn't a separate pure lua module file.
* add tohex function, to convert any binary string into hex mode.
* import sum and sumhexa function to support calculate hash in segments.

now sum can accept a second state argument. the semantics just
borrowed from slncrypto[2]:

md5.sum(data)
	returns the 16 byte MD5 digest as a string.
md5.sum(data, state)
	if data length is a multiple of 64 byte and not 0,
		returns a state, which is a string of digest, blank and a decimal number
	else only the digest
	use "" as initial state

the same as sumhexa function.

[1] http://www.keplerproject.org/md5/
[2] http://lua-users.org/lists/lua-l/2005-02/msg00744.html

Attachment: md5.zip
Description: Zip archive