feature: support stream ?
tst2005 opened this issue · comments
For the fun and just for the fun
I made a funny ugly hack to create a fake string from file-descriptor
The sha1 require #str
, string.byte(str, i, j)
and a concat operation.
See https://github.com/tst2005/lua-fd2string
Yeah that seems somewhat suboptimal...
Copying interface draft:
local state = sha1.new()
state:add(some_input) -- Not necessarily a multiple of block size
state:add(some_input)
...
local hex_sha1 = state.sha1()) -- sha1 of all collected inputs in hex
local bin_sha1 = state.binary() -- sha1 of all collected inputs in binary
state:add(some_input) -- Can keep adding inputs
Python's hashlib uses update
instead of add
.
I've heard of lockbox before, looks like it doesn't really try to optimize for performance, and it doesn't provide a pure Lua version for Lua 5.1 itself either.
http://lua-users.org/lists/lua-l/2018-11/msg00114.html
Thanks for all work you done.
Rest in pease my friend.