Use hex literals everywhere

This commit is contained in:
kikito 2015-04-06 18:34:11 +02:00
parent 4e68bf98a8
commit f253f5ffd5
1 changed files with 4 additions and 5 deletions

View File

@ -166,7 +166,7 @@ else
if(n < 0) then if(n < 0) then
-- negative -- negative
n = bit_not(math.abs(n)) + 1 n = bit_not(math.abs(n)) + 1
high_bit = 2147483648 -- 0x80000000 high_bit = 0x80000000
end end
local floor = math.floor local floor = math.floor
@ -187,7 +187,7 @@ else
for i=1, bits do for i=1, bits do
n = n*2 n = n*2
end end
return bit_and(n, 4294967295) -- 0xFFFFFFFF return bit_and(n, 0xFFFFFFFF)
end end
end end
@ -240,7 +240,6 @@ end
-- An MD5 mplementation in Lua, requires bitlib (hacked to use LuaBit from above, ugh) -- An MD5 mplementation in Lua, requires bitlib (hacked to use LuaBit from above, ugh)
-- 10/02/2001 jcw@equi4.com -- 10/02/2001 jcw@equi4.com
local FF = 0xffffffff
local CONSTS = { local CONSTS = {
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
@ -266,9 +265,9 @@ local g=function (x,y,z) return bit_or(bit_and(x,z),bit_and(y,-z-1)) end
local h=function (x,y,z) return bit_xor(x,bit_xor(y,z)) end local h=function (x,y,z) return bit_xor(x,bit_xor(y,z)) end
local i=function (x,y,z) return bit_xor(y,bit_or(x,-z-1)) end local i=function (x,y,z) return bit_xor(y,bit_or(x,-z-1)) end
local z=function (f,a,b,c,d,x,s,ac) local z=function (f,a,b,c,d,x,s,ac)
a=bit_and(a+f(b,c,d)+x+ac,FF) a=bit_and(a+f(b,c,d)+x+ac,0xFFFFFFFF)
-- be *very* careful that left shift does not cause rounding! -- be *very* careful that left shift does not cause rounding!
return bit_or(bit_lshift(bit_and(a,bit_rshift(FF,s)),s),bit_rshift(a,32-s))+b return bit_or(bit_lshift(bit_and(a,bit_rshift(0xFFFFFFFF,s)),s),bit_rshift(a,32-s))+b
end end
local function transform(A,B,C,D,X) local function transform(A,B,C,D,X)