strawberryscripts

Emoji Secure

May 14th, 2021 (edited)
716
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- The ultimate Lua encryption tool for Roblox (Works 70% of the time)
  2.  
  3. local Body = game:HttpGet('https://unpkg.com/emoji.json@13.1.0/emoji-compact.json')
  4. local Emojis = game.HttpService:JSONDecode(Body)
  5.  
  6. local Numbers = {}
  7. local EmojiSecure = {}
  8. local EmojiCharacters = {}
  9.  
  10. function EmojiSecure:GenerateNumber(From, To)
  11.     local Number = 0
  12.     repeat
  13.         Number = math.random(From or 1, To or 1000)
  14.     until not table.find(Numbers, Number)
  15.     return Number
  16. end
  17.  
  18. function EmojiSecure:ReverseTable(Table)
  19.     local NewTable = {}
  20.  
  21.     for X, Y in pairs(Table) do
  22.         NewTable[Y] = X
  23.     end
  24.    
  25.     return NewTable
  26. end
  27.  
  28. function EmojiSecure:SplitByEmoji(Text)
  29.     local SplitEmojis = {}
  30.    
  31.     for Emoji in Text
  32.         :gsub("(.)([\194-\244])", "%1\0%2")
  33.         :gsub("%z(\240\159\143[\187-\191])", "%1")
  34.         :gsub("%z(\239\184[\128-\143])", "%1")
  35.         :gsub("%z(\226\128\141)%z", "%1")
  36.         :gmatch("%Z+")
  37.     do
  38.         table.insert(SplitEmojis, Emoji)
  39.     end
  40.    
  41.     return SplitEmojis
  42. end
  43.  
  44. function EmojiSecure:Encode(Text)
  45.     local Encoded = ''
  46.    
  47.     for Integer, Character in pairs(Text:split('')) do
  48.         local Emoji = EmojiCharacters[Character:byte()]
  49.  
  50.         local EmojiByte = Emoji:gsub('.', function(Byte)
  51.             return "\\" .. Byte:byte()
  52.         end)
  53.  
  54.         Encoded ..= EmojiByte
  55.     end
  56.    
  57.     return Encoded
  58. end
  59.  
  60. function EmojiSecure:Decode(Text)
  61.     local Decoded = ""
  62.     local CharacterEmoji = EmojiSecure:ReverseTable(EmojiCharacters)
  63.    
  64.     for Integer, Emoji in pairs(EmojiSecure:SplitByEmoji(Text)) do
  65.         if CharacterEmoji[Emoji] then
  66.             Decoded ..= "\\" .. CharacterEmoji[Emoji]
  67.         end
  68.     end
  69.  
  70.     return loadstring("return '" .. Decoded .. "'")()
  71. end
  72.  
  73. for Integer = 1, 255 do
  74.     local Number = EmojiSecure:GenerateNumber(1, #Emojis)
  75.     local Emoji = Emojis[Number]
  76.  
  77.     EmojiCharacters[Integer] = Emoji
  78. end
  79.  
  80. return EmojiSecure
  81.  
  82. --[[ Example usage
  83.  
  84. local EmojiSecure = loadstring(game:HttpGet('https://pastebin.com/raw/qqCVppSE'))() -- Loading in the module
  85.  
  86. local Encoded = EmojiSecure:Encode('print("Emoji Secure on top!")') -- Encoding it into emojis, then bytes
  87. local Decoded = EmojiSecure:Decode(loadstring("return '" .. Encoded .. "'")()) -- Decoding the correct value
  88.  
  89. loadstring(Decoded)() -- Loading the decoded value
  90.  
  91. ]]
  92.  
RAW Paste Data