makes update return self

This commit is contained in:
kikito 2016-07-15 01:16:54 +02:00
parent 46b50003f8
commit 86da43dbda

View File

@ -353,6 +353,7 @@ local function md5_update(self, s)
self.a,self.b,self.c,self.d = transform(self.a,self.b,self.c,self.d,X) self.a,self.b,self.c,self.d = transform(self.a,self.b,self.c,self.d,X)
end end
self.buf = sub(s, math.floor(#s/64)*64 + 1, #s) self.buf = sub(s, math.floor(#s/64)*64 + 1, #s)
return self
end end
local function md5_finish(self) local function md5_finish(self)
@ -370,6 +371,8 @@ local function md5_finish(self)
return lei2str(self.a) .. lei2str(self.b) .. lei2str(self.c) .. lei2str(self.d) return lei2str(self.a) .. lei2str(self.b) .. lei2str(self.c) .. lei2str(self.d)
end end
----------------------------------------------------------------
function md5.new() function md5.new()
return { a = CONSTS[65], b = CONSTS[66], c = CONSTS[67], d = CONSTS[68], return { a = CONSTS[65], b = CONSTS[66], c = CONSTS[67], d = CONSTS[68],
pos = 0, pos = 0,
@ -383,9 +386,7 @@ function md5.tohex(s)
end end
function md5.sum(s) function md5.sum(s)
local state = md5.new() return md5.new():update(s):finish()
state:update(s)
return state:finish()
end end
function md5.sumhexa(s) function md5.sumhexa(s)