A small, unfinished (there's no decoder yet) little program that shows how to encode 32-table characters (5bit) to a complete ascii set (8bit). The advantage is that your data becomes encrypted AND is reduced in size. On normal strings the reduction is about 60%. Since all alphanumeric characters together are already more than 5bits, we use multiple 5bit tables with a switching index:
Here you see both the LUT (look-up-tables). The left one is the default one, so we always start here. If we need to include a character from the other LUT then we first need to add a switch code. If we start counting at 0 this equals 31. So let's pretend we are currently in the left LUT. If we now want to encode the string "ABC 123" then we get:
| 1. | 10 (this means "A". If the second LUT would be default this would mean "@")
|
2. 23 ("B")
3. 21 ("C")
4. 28 (Space)
5. 31 (Switching code, we now use the other LUT)
6. 0 (index 0 of the second LUT equals "1")
7. 1 ("2")
8. 2 ("3")
Of course the way in which the characters are ordered is completely irrelevant. You can also add more LUTs at will. If -for example- you also want to support lower-case characters, you're going to need a third LUT.
Once you have the series of numbers (all ranging between 0 and 31) you have to translate them to binary code (actually the computer already does this automatically, but in this application, I create a string that represents the binary stream.). 5bit binary code looks like this:
00110 11000 00010 11100 11011 11110
Since we'll be encoding this into 8bit ASCII characters we have to regroup the individual bits into this:
00110110 00000101 11001101 111110xx
We need to add 2 bits to the last piece to fill the 8bit pattern. Every block of 8 bits represents a number in the range 0-255. Now you are done. A 5bit string has been encoded into an 8bit string.
RECONSTRUCTIVISM.NET -> ª,5H{yÖ
For additional information.