function Base64.Encode(m,D)local T={}local Q=0 for m=1,#D,3 do local f,k,L=string.byte(D,m,m+2)local F=bit32_rshift(f,2)local y=bit32_lshift(bit32_band(f,3),4)+bit32_rshift(k or 0,4)local s=bit32_lshift(bit32_band(k or 0,15),2)+bit32_rshift(L or 0,6)local o=bit32_band(L or 0,63)T[Q+1]=Alphabet[F+1]T[Q+2]=Alphabet[y+1]T[Q+3]=k and Alphabet[s+1]or 61 T[Q+4]=L and Alphabet[o+1]or 61 Q=Q+4 end local f={}local k=0 for D=1,Q,4096 do k=k+1 f[k]=string.char(table.unpack(T,D,math.min((D+4096)-1,Q)))end return table.concat(f)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)

		Output[Length + 1] = Alphabet[A + 1]
		Output[Length + 2] = Alphabet[B + 1]
		Output[Length + 3] = C2 and Alphabet[C + 1] or 61
		Output[Length + 4] = C3 and Alphabet[D + 1] or 61
		Length = Length + 4
	end

	local NewOutput = {}
	local NewLength = 0

	for Index = 1, Length, 4096 do
		NewLength = NewLength + 1
		NewOutput[NewLength] = string.char(table.unpack(Output, Index, math.min(Index + 4096 - 1, Length)))
	end

	return table.concat(NewOutput)
end
