refactor to_bits

This commit is contained in:
kikito 2015-04-06 17:37:16 +02:00
parent 332517912d
commit 858b23b28d
1 changed files with 6 additions and 9 deletions

15
md5.lua
View File

@ -100,15 +100,12 @@ else
-- to bits table -- to bits table
local tbl = {} local tbl = {}
local cnt = 1 local cnt = 1
while (n > 0) do local last
local last = math.mod(n,2) while n > 0 do
if(last == 1) then last = n % 2
tbl[cnt] = 1 tbl[cnt] = last
else n = (n-last)/2
tbl[cnt] = 0 cnt = cnt + 1
end
n = (n-last)/2
cnt = cnt + 1
end end
return tbl return tbl