A side effect of using every character in a number base is that you can treat any text as if it is a number. This isn’t entirely a new idea, Donald Knuth’s The Art of Computer Programming has an exercise to convert a series of octal numbers into hexadecimal numbers that when done gives the following: A BAD AD0BE FACADE FADED*.
However, that only used a few characters and several numbers. But now with a system that can handle every character, we can take that sentence (lower case some letters, swap out the 0 for an ‘o’) and treat it as a single number in base 95 (to handle the space character as a value as well) to a single value in base 8. So the sentence ‘A bad adobe facade faded’ in base 95 is 2753133740175434660002661231115005054166037305555075 in base 8.
Another example, here is a poem chunk:
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
Treating this as a single number in base 97 (new lines and all), it becomes the following in base -43:
P5EIXNUOYOc1332d4XSDc1G7ZbHF314OIK6Uf1aFd8GWgWJFZ4SYW1UBH7GKD3Af1Q4G1L2UMP2QeEEY0V37GHd8g2OUOUHLf8a70Q807aKCPYKfIg93XF6EX4PMVJC8ggCFScLJGC2NNMR6SCTK1e686AR28E1N0gLebFd0T4WVT6A
You could also treat it as a number in base -126 and still convert it to base -43. In that case you instead get: 1OWAUH6V3dT90PObB5A7TbWOUXIJdYVgVGIHQT16NK5F7eZcRg8WYGC55MT9DQOMPKWWcf28Se1ZSF7TXE3E4QWdc7VFaOg5e8WT6EId52S8AYBTYTQLT8e19Xe1Q6fSHXZMe9JE7ECBO8AVMB40PTgP04BLNVVO5E3LFWR5MLdbFI3OYR5M5P0YXg
So why would you want to do this? Well for one if you’re writing a textbook on computer programming you can put it in as a problem for the reader to work out. There’s also the novelty of using it.
But I think it could be used as an encryption method; either by itself or in conjunction with other methods. You would need to keep the two bases you used (initial base, converted base) as keys. You could also obfuscate the base encryption by mixing up the order of the character values. Instead of starting with the characters 0123456789ABC… you could have it so 0 uses the ~ character, 1 assigned to the ¿ character and so on. You’d have to keep track of that as well, preferably in a private, separate location.
So say you have the following password, ‘correct horse battery staple’; you encrypt it with the keys -3956 and 778(the bases you’re starting with and ending with) and the standard character-value assignment (0123456789ABCDE…) and you’ll end up with a mess that looks like this**:
-2džàɤȱǗ,ˌ|ȊWƁɯſȓȮÇʒƶʍʕɞ˼űĐłȉƆĠá
(it’s really u’-2\u01c6\xe0\u0264\u0231\u01d7,\u02cc|\x10\u020aW\u0181\x94\x19\u026f\u017f\u0213\u022e\xc7\u0292\u01b6\u028d\x1c\u0295\u025e\u02fc\u0171\u0110\u0142\u0209\u0186\x9c\u0120\xe1′ but who cares? You should!)
This along with the keys is what you would store then. You could use any integer as a starting key(though I don’t recommend keys that are within -1 to 1) but your ending key should be within a range that has enough characters. Though I suppose you could just store the string of numbers that you would get back if you didn’t have sufficient characters. Bases as keys will get more interesting when I get to real number bases.
You could also “salt” the password by either adding some text to the end of the password (‘…staple +blargh!’), or convert the password to base 10, add or multiply some number to that, then take that resulting value and continue onto your ending base. Or you could do the regular password hashing, then base encrypt the resulting hash. I’m just guessing at the use of or how to use number bases as an encryption method so the idea might (most likely) need some work.
*Second edition, Volume 2 – Seminumerical Algorithms, pg 194. Yes, I dug the book out of the library; it was faster and easier than trying to find the book online.
**with my code any base above 98 will be dependent on your computer’s Unicode encoding, so it might be best to nail all the characters down in the order you want.
Leave a comment