function Base64.Encode(U)local f={}local j=0 for M=1,#U,3 do local n,o,H=string.byte(U,M,M+2)local y=bit32_rshift(n,2)local V=bit32_lshift(bit32_band(n,3),4)+bit32_rshift(o or 0,4)local u=bit32_lshift(bit32_band(o or 0,15),2)+bit32_rshift(H or 0,6)local W=bit32_band(H or 0,63)j=j+1 f[j]=Alphabet[y+1]j=j+1 f[j]=Alphabet[V+1]j=j+1 f[j]=o and Alphabet[u+1]or 61 j=j+1 f[j]=H and Alphabet[W+1]or 61 end local M={}local n=0 local o for U=1,j,4096 do n=n+1 o=(U+4096)-1 M[n]=string.char(table.unpack(f,U,o>j and j or o))end return table.concat(M)end

function Base64.Encode(Input)
	local Output = {}
	local Length = 0

	for Index = 1, #Input, 3 do
		local C1, C2, C3 = string.byte(Input, Index, Index + 2)

		local A = bit32_rshift(C1, 2)
		local B = bit32_lshift(bit32_band(C1, 3), 4) + bit32_rshift(C2 or 0, 4)
		local C = bit32_lshift(bit32_band(C2 or 0, 15), 2) + bit32_rshift(C3 or 0, 6)
		local D = bit32_band(C3 or 0, 63)

		Length = Length + 1
		Output[Length] = Alphabet[A + 1]

		Length = Length + 1
		Output[Length] = Alphabet[B + 1]

		Length = Length + 1
		Output[Length] = C2 and Alphabet[C + 1] or 61

		Length = Length + 1
		Output[Length] = C3 and Alphabet[D + 1] or 61
	end

	local NewOutput = {}
	local NewLength = 0
	local IndexAdd4096Sub1

	for Index = 1, Length, 4096 do
		NewLength = NewLength + 1
		IndexAdd4096Sub1 = Index + 4096 - 1

		NewOutput[NewLength] = string.char(table.unpack(
			Output,
			Index,
			IndexAdd4096Sub1 > Length and Length or IndexAdd4096Sub1
		))
	end

	return table.concat(NewOutput)
end
