Conditions:

  1. Packaging must be reversible, of course.
  2. Characters - from a set of non-coded for URIs
  3. Under no circumstances can the length of the result string be greater than the length of the text representation of the source number.

Such an option is proposed: to transfer to the 36-th SS. 36 simply because there are so many characters in the set "0-9,az" . That is, for example, the number 1234567890987654321 will turn into 9do1sjhjpekg . You can increase the base by introducing the "numbers" . (dot), - (hyphen) etc, but in principle it will change a little.

More versions?

  • archiver + substitution cipher, modulo arithmetic, coding eg: uk.wikipedia.org/wiki/Huffman_code - jmu
  • I wanted to write "not to offer the archiver", but did not think that someone could seriously do it ... OK, I will add the third condition. - user6550
  • It seems to me that theoretically the best packaging would be an entry in the system on the basis of n , where n is the total number of non-encoded characters for URIs. Is not it so? - VladD
  • @KoVadim, because it is substituted in the URL. - user6550
  • @VladD, I did it, well, except maybe I deleted some characters to improve the visual presentation. Although automation is all the same, of course. Just suddenly, what else comes up :) - user6550

1 answer 1

And why not use the capital? That is, the range is 0-9a-zA-Z and plus two more characters (for example, a dot and an underscore). The result will be 64 characters, which greatly simplify the translation. And the most fun - it just will be a modification of base64 . (although what kind of modification it is, you just need to prepare the data).

  • > The main thing to go according to the standard. Yes, something I didn’t bother about the case :) In the process, a by -product was riveted, it seems to work, on the bottom 62 :) - user6550