Both proposed solutions require some knowledge of the range of keys accepted.
To avoid this assumption, you can combine the numbers.
Key1 = ABC => Digits = A, B, C
Key2 = 123 => Digits = 1, 2, 3
Riffle(Key1, Key2) = A, 1, B, 2, C, 3
Zero-padding can be used when there are not enough numbers:
Key1 = 12345, Key2 = 1 => 1020304051
This method also generalizes for any number of keys.
source share