I have a function that takes arrays with numbers between 0 and 255(representing a byte) and converts them to arrays of numbers between 0 and 93. This is done through the following process:
local function base94encode(bytes: {number}): {number}
local encoded = {}
local carry = 0
for i = #bytes, 1, -1 do
local value = bytes[i]+carry
carry = math.floor(value/94)
table.insert(encoded, 1, value%94)
end
while carry > 0 do
table.insert(encoded, 1, carry%94)
carry = math.floor(carry/94)
end
return encoded
end
The question is how to reverse that, so I can write my base94decode
function, but in a carry-bit like manner(not storing everything in a big number variable, etc).