Commit b4f0c2d1 authored by Luna's avatar Luna
Browse files

another one

parent ba39d096
...@@ -4,7 +4,8 @@ local tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' ...@@ -4,7 +4,8 @@ local tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
base64 = { base64 = {
enc = function(data) enc = function(data)
local l,out = 0,'' local l,out = 0,''
local d = data..string.rep('\0',(3-data:len()%3)%3) local m = (3-data:len()%3)%3
local d = data..string.rep('\0',m)
for i=1,d:len() do for i=1,d:len() do
l = bit.lshift(l,8) l = bit.lshift(l,8)
l = l+d:byte(i,i) l = l+d:byte(i,i)
...@@ -16,7 +17,7 @@ base64 = { ...@@ -16,7 +17,7 @@ base64 = {
end end
end end
end end
return out..({'','==','='})[data:len()%3+1] return out:sub(1,-1-m)..string.rep('=',m)
end, end,
dec = function(data) dec = function(data)
local a,b = data:gsub('=','A') local a,b = data:gsub('=','A')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment