lua-zlib
lua-zlib copied to clipboard
add checksum functions and tobinary functions
- port crc32 and adler32 functions to lua.
- add a function convert int32 checksum to string.
Okay, I have added the documents and test cases, and remove the tobinary function :)
Sorry for being slow on the uptake here... after thinking about this a bit, I'm proposing a function factory interface that more closely mirrors the compression interface:
https://github.com/brimworks/lua-zlib/commit/f94aabf944581df865e70b7943962fa18c9d0838
Specifically you can do this:
-- All in one call:
local csum = zlib.crc32()("one two")
-- Multiple calls:
local compute = zlib.crc32()
compute("one")
assert(csum == compute(" two"))
-- Multiple compute_checksums joined:
local compute1, compute2 = zlib.crc32(), zlib.crc32()
compute1("one")
compute2(" two")
assert(csum == compute1(compute2))
Feedback is welcomed.