Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function table.encrypt(tableC, password, password2)
- if not tableC or not password or not password2 or type(tableC)~='table' or password=='' or password2=='' then
- return
- end
- local initSeed, finalString, newMessage, key='', '', '', ''
- for i in password:gmatch('.') do
- initSeed=initSeed..i:byte()
- end
- for i in password2:gmatch('.') do
- key=key..i:byte()
- end
- math.randomseed(initSeed)
- otherSeed=math.random(1000000)
- local action=pcall(function()
- for i, v in next, tableC do
- if type(v)=='string' or type(v)=='number' then
- if type(v)=='string' then
- v=[[']]..v..[[']]
- end
- newMessage=newMessage..' '..v..' '..i:upper()
- else
- return
- end
- end
- newMessage=newMessage..' '..key
- for i in newMessage:gmatch('.') do
- local newByte=i:byte() + 68 + math.random(5)
- otherSeed=otherSeed + i:byte()
- math.randomseed(otherSeed)
- if (newByte>=65 and newByte <= 122) and not (newByte>=91 and newByte <= 96) then
- newByte=string.char(newByte)
- end
- finalString=finalString..newByte
- end
- end)
- math.randomseed(os.time())
- if not action then
- return
- else
- return finalString
- end
- end
- function table.decrypt(stringC, password, password2)
- if not stringC or not password or not password2 or type(stringC)~='string' or password=='' or password2=='' then return end
- local initSeed, finalString, aByte, key='', '', '', ''
- for i in password:gmatch('.') do
- initSeed=initSeed..i:byte()
- end
- for i in password2:gmatch('.') do
- key=key..i:byte()
- end
- math.randomseed(initSeed)
- otherSeed=math.random(1000000)
- local action=pcall(function()
- for i in stringC:gmatch('.') do
- if i:byte()>=65 and i:byte() <= 122 then
- local newByte=i:byte() - 68 - math.random(5)
- otherSeed=otherSeed + newByte
- math.randomseed(otherSeed)
- finalString=finalString..string.char(newByte)
- else
- aByte=aByte..i
- if aByte:len()>=3 then
- local newByte=tonumber(aByte) - 68 - math.random(5)
- otherSeed=otherSeed + newByte
- math.randomseed(otherSeed)
- finalString=finalString..string.char(newByte)
- aByte=''
- end
- end
- end
- end)
- math.randomseed(os.time())
- if not action then
- return
- else
- local finalTable, stage, fsLength, aString, aNumber={}, 0, 0
- for i, v in string.gmatch(finalString, '[^%s]+') do
- fsLength=fsLength + 1
- end
- for i, v in string.gmatch(finalString, '[^%s]+') do
- stage=stage + 1
- if stage==fsLength and i~=key then
- return
- elseif aString then
- if aString:sub(-1)==[[']] then
- finalTable[i:lower()]=aString:gsub([[']], '')
- aString=nil
- else
- aString=aString..' '..i
- end
- elseif aNumber then
- finalTable[i:lower()]=aNumber
- aNumber=nil
- elseif i:sub(1, 1)==[[']] then
- aString=i
- else
- aNumber=i
- end
- end
- return finalTable
- end
- end
- local dbPassword,key='henin00b<3','henim1t0<3'
- p={}
- function eventNewPlayer(n)
- p[n]={save={id=tfm.get.room.playerList[n].id,points=5},time=os.time()+5000}
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- local c={"map","lang","profile","pr","p","leaderboard","rank","help","pw"}
- function eventChatCommand(n,cmd)
- local c={}
- for i in cmd:gmatch('[^%s]+') do
- table.insert(c,i)
- end
- c[1]=c[1]:lower()
- if c[1]=="load" and c[2] then
- local gen=table.decrypt(c[2], dbPassword, key)
- if gen and tonumber(gen.id)==tfm.get.room.playerList[n].id then
- p[n].save=gen
- end
- elseif c[1]=="save" and p[n].time < os.time() then
- p[n].time=os.time()
- local gen=(table.encrypt(p[n].save, dbPassword, key))
- tfm.exec.chatMessage(gen,n)
- elseif c[1]=="point" then
- p[n].save.points=p[n].save.points+1
- elseif c[1]=="?" then
- tfm.exec.chatMessage(p[n].save.points,n)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement