Advertisement
Lanzr

tst_token

Dec 8th, 2023 (edited)
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. local function enc(data)
  2.         return ((data:gsub('.', function(x)
  3.                 local r,b='',x:byte()
  4.                 for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
  5.                 return r;
  6.         end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
  7.                 if (#x < 6) then return '' end
  8.                 local c=0
  9.                 for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
  10.                 return b:sub(c+1,c+1)
  11.         end)..({ '', '==', '=' })[#data%3+1])
  12. end
  13.  
  14.  
  15. local function genToken(user, pass)
  16.         local userp = user..":"..pass
  17.         return "Basic "..enc(userp)
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement