local Base2 = {
[0] = 1,
[1] = 2,
[2] = 4,
[3] = 8,
[4] = 16,
[5] = 32,
[6] = 64,
[7] = 128,
}
local Encoded = 0
function Decode(Byte: string)
local Bits = {
[1] = "0",
[2] = "0",
[3] = "0",
[4] = "0",
[5] = "0",
[6] = "0",
[7] = "0",
[8] = "0"
}
for i = 1, Byte:len() do
local Bit = Byte:reverse():sub( i , i )
Bits[i] = Bit
end
for i = 1, #Bits do
Encoded = Encoded + ( Binary.Base2[ i - 1 ] * tonumber(Bits[i], 10))
end
return Encoded
end
This works perfectly well though I want to take some feedback from the community if my script is well optimized, and get some certain advice. All though, this can only decode up to a byte
of information.