The approach used by the demo is to encode each categorical value on the fly. An alternative, which is more efficient but slightly more complicated, is to precompute all possible categorical values, ...
What are the numbers? You can encode 9,999,999,999 in 5 bytes. If you want to store the number in human readable bytes, convert it to Base64 encoding or similar.