MODFINDER_STOCK_MODS

encoder/decoder lua

Jul 3rd, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. function base64.decode(data)
  2. data = string.gsub(data, '[^' .. b .. '=]', '')
  3. local decoded = (data:gsub('.', function(x)
  4. if (x == '=') then
  5. return ''
  6. end
  7. local r, f = '', (b:find(x) - 1)
  8. for i = 6, 1, -1 do
  9. r = r .. (f % 2^i - f % 2^(i - 1) > 0 and '1' or '0')
  10. end
  11. return r
  12. end):gsub('%d%d%d%d%d%d%d%d', function(x)
  13. local c = 0
  14. for i = 1, 8 do
  15. c = c + (x:sub(i, i) == '1' and 2^(8 - i) or 0)
  16. end
  17. return string.char(c)
  18. end))
  19. return decoded
  20. end
  21. local utf8DecodedData = base64.decode(base64.decode(e))
  22. utf8DecodedData = utf8DecodedData:gsub('.', function(c)
  23. return utf8.char(utf8.codepoint(c))
  24. end)
Add Comment
Please, Sign In to add comment