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
local tbl = {}
local cnt = 1
while (n > 0) do
local last = math.mod(n,2)
if(last == 1) then
tbl[cnt] = 1
else
tbl[cnt] = 0
end
n = (n-last)/2
cnt = cnt + 1
local last
while n > 0 do
last = n % 2
tbl[cnt] = last
n = (n-last)/2
cnt = cnt + 1
end
return tbl