From 86da43dbda40354830d629168c24aade004af2a9 Mon Sep 17 00:00:00 2001 From: kikito Date: Fri, 15 Jul 2016 01:16:54 +0200 Subject: [PATCH] makes update return self --- md5.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/md5.lua b/md5.lua index 4828b53..93ae756 100644 --- a/md5.lua +++ b/md5.lua @@ -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) end self.buf = sub(s, math.floor(#s/64)*64 + 1, #s) + return self end 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) end +---------------------------------------------------------------- + function md5.new() return { a = CONSTS[65], b = CONSTS[66], c = CONSTS[67], d = CONSTS[68], pos = 0, @@ -383,9 +386,7 @@ function md5.tohex(s) end function md5.sum(s) - local state = md5.new() - state:update(s) - return state:finish() + return md5.new():update(s):finish() end function md5.sumhexa(s)