For example, the space character (ASCII $20) would represent 0, "!" represents 1, etc.
The string "1234" in ASCII-hex is:
$31 $32 $33 $34
But these bytes range from $20-$7F (32-127 in decimal). To get their actual values, all you have to do is subtract $20 from each byte. Using the above as an example, you get:
$11 $12 $13 $14
That represents the digits 17, 18, 19, and 20 in base-96. Now, if you were to interpret these in little-endian order (least significant digit first), you would get this result:
17 * 96^0 + 18 * 96^1 + 19 * 96^2 + 20 * 96^3 = 17,871,569
One of the most intriguing things about base-96 is encryption. There can be many different ways of doing so. One obvious way is to just simply add an offset (ranging from 0-95), then subtracting 96 if the result is 96 or greater. Assume that the byte value ranges from 0-95, not 32-127. In C++, this is represented by:
Code: Select all
c[n] = (c[n] + k) % 96; // c[n] = digit in base-96, k = offset (0-95)
Code: Select all
move.b (a0),d0
addi.b #k,d0
cmpi.b #96,d0
bcs.b .1
subi.b #96,d0
.1:
move.b d0,(a0)
Code: Select all
c[n] = c[n] ^ k; // c[n] = digit in base-96, k = offset (0-31)
Code: Select all
move.b (a0),d0
eori.b #k,d0
move.b d0,(a0)