added a library for challenge authentication using CRC32 as the hash. will be improved to use better stuff later

This commit is contained in:
Izaya 2017-06-19 13:19:56 +00:00
parent 6c5a2dce4c
commit 206da60f0f

View File

@ -0,0 +1,23 @@
function chauths(cA,nP,pW)
C.yield()
C.yield()
local rs=""
for i = 1, 16 do rs=rs..string.char(math.random(33,126)) end
ns(cA,nP,"char,"..rs)
while true do
if ev[1] == "net_msg" and ev[2] == cA and ev[3] == nP then
return (ev[4] == "chaa,"..string.format("%x",crc32.hash(pW..rs)))
end
C.yield()
end
end
function chauthc(sA,nP,pW)
while true do
if ev[1] == "net_msg" and ev[2] == sA and ev[3] == nP and ev[4]:sub(1,5) == "char," then
ns(sA,nP,"chaa,"..string.format("%x",crc32.hash(pW..ev[4]:sub(6))))
break
end
C.yield()
end
end