Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. function table.encrypt(tableC, password, password2)
  2. if not tableC or not password or not password2 or type(tableC)~='table' or password=='' or password2=='' then
  3. return
  4. end
  5. local initSeed, finalString, newMessage, key='', '', '', ''
  6. for i in password:gmatch('.') do
  7. initSeed=initSeed..i:byte()
  8. end
  9. for i in password2:gmatch('.') do
  10. key=key..i:byte()
  11. end
  12. math.randomseed(initSeed)
  13. otherSeed=math.random(1000000)
  14. local action=pcall(function()
  15. for i, v in next, tableC do
  16. if type(v)=='string' or type(v)=='number' then
  17. if type(v)=='string' then
  18. v=[[']]..v..[[']]
  19. end
  20. newMessage=newMessage..' '..v..' '..i:upper()
  21. else
  22. return
  23. end
  24. end
  25. newMessage=newMessage..' '..key
  26. for i in newMessage:gmatch('.') do
  27. local newByte=i:byte() + 68 + math.random(5)
  28. otherSeed=otherSeed + i:byte()
  29. math.randomseed(otherSeed)
  30. if (newByte>=65 and newByte <= 122) and not (newByte>=91 and newByte <= 96) then
  31. newByte=string.char(newByte)
  32. end
  33. finalString=finalString..newByte
  34. end
  35. end)
  36. math.randomseed(os.time())
  37. if not action then
  38. return
  39. else
  40. return finalString
  41. end
  42. end
  43.  
  44. function table.decrypt(stringC, password, password2)
  45. if not stringC or not password or not password2 or type(stringC)~='string' or password=='' or password2=='' then return end
  46. local initSeed, finalString, aByte, key='', '', '', ''
  47. for i in password:gmatch('.') do
  48. initSeed=initSeed..i:byte()
  49. end
  50. for i in password2:gmatch('.') do
  51. key=key..i:byte()
  52. end
  53. math.randomseed(initSeed)
  54. otherSeed=math.random(1000000)
  55. local action=pcall(function()
  56. for i in stringC:gmatch('.') do
  57. if i:byte()>=65 and i:byte() <= 122 then
  58. local newByte=i:byte() - 68 - math.random(5)
  59. otherSeed=otherSeed + newByte
  60. math.randomseed(otherSeed)
  61. finalString=finalString..string.char(newByte)
  62. else
  63. aByte=aByte..i
  64. if aByte:len()>=3 then
  65. local newByte=tonumber(aByte) - 68 - math.random(5)
  66. otherSeed=otherSeed + newByte
  67. math.randomseed(otherSeed)
  68. finalString=finalString..string.char(newByte)
  69. aByte=''
  70. end
  71. end
  72. end
  73. end)
  74. math.randomseed(os.time())
  75. if not action then
  76. return
  77. else
  78. local finalTable, stage, fsLength, aString, aNumber={}, 0, 0
  79. for i, v in string.gmatch(finalString, '[^%s]+') do
  80. fsLength=fsLength + 1
  81. end
  82. for i, v in string.gmatch(finalString, '[^%s]+') do
  83. stage=stage + 1
  84. if stage==fsLength and i~=key then
  85. return
  86. elseif aString then
  87. if aString:sub(-1)==[[']] then
  88. finalTable[i:lower()]=aString:gsub([[']], '')
  89. aString=nil
  90. else
  91. aString=aString..' '..i
  92. end
  93. elseif aNumber then
  94. finalTable[i:lower()]=aNumber
  95. aNumber=nil
  96. elseif i:sub(1, 1)==[[']] then
  97. aString=i
  98. else
  99. aNumber=i
  100. end
  101. end
  102. return finalTable
  103. end
  104. end
  105.  
  106. local dbPassword,key='henin00b<3','henim1t0<3'
  107. p={}
  108.  
  109. function eventNewPlayer(n)
  110. p[n]={save={id=tfm.get.room.playerList[n].id,points=5},time=os.time()+5000}
  111. end
  112. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  113.  
  114. local c={"map","lang","profile","pr","p","leaderboard","rank","help","pw"}
  115. function eventChatCommand(n,cmd)
  116. local c={}
  117. for i in cmd:gmatch('[^%s]+') do
  118. table.insert(c,i)
  119. end
  120. c[1]=c[1]:lower()
  121. if c[1]=="load" and c[2] then
  122. local gen=table.decrypt(c[2], dbPassword, key)
  123. if gen and tonumber(gen.id)==tfm.get.room.playerList[n].id then
  124. p[n].save=gen
  125. end
  126. elseif c[1]=="save" and p[n].time < os.time() then
  127. p[n].time=os.time()
  128. local gen=(table.encrypt(p[n].save, dbPassword, key))
  129. tfm.exec.chatMessage(gen,n)
  130. elseif c[1]=="point" then
  131. p[n].save.points=p[n].save.points+1
  132. elseif c[1]=="?" then
  133. tfm.exec.chatMessage(p[n].save.points,n)
  134. end
  135. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement