Encoding / Compressing a Large Integer to an Alphanumeric Value

I have a very large integer of 12-14 digits, and I want to encrypt / compress this to an alphanumeric value so that the integer can be recovered later from the alphanumeric value. I tried converting this integer using base 62 and tried to match these values ​​with a-zA-Z0-9, but the value generated from this is 7 characters. This length is still long enough, and I want to convert it to about 4-5 characters.

Is there a general way to do this or some method in which this can be done so that integer recovery would be possible? I am asking the mathematical aspects here, but I would program it in PHP, and recently I started programming in php.

Edit:

I thought about assigning a masking bit and used it in such a way as to generate fewer characters. I am aware of the fact that the range is not enough, and that is why I focused on using a mathematical trick or presentation method. Base 62 was an idea that I have already applied, but does not work.

+4
source share
3 answers

14-digit decimal numbers can express 100,000,000,000,000 values ​​(10 14 ).
5 characters from a 62-character alphabet can express 916,132,832 values ​​(62 5 ).

14- 5 base 62. . . http://en.wikipedia.org/wiki/Pigeonhole_principle. 64 7 ( 4 398 046 511 104 ). , 5 , , 631 (631 5= 100,033,806,792,151).

. , ( ), , .

: , " " . 0 1. 2 . , , .... 100 000 000 000 000 ? , , .

+5

95 ASCII- base 95 62:

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

, X Y base 95 string,

Y = X * log 10/ log 95 = roughly X / 2

. , 12 6. JSON, 92 ( ",\,/, JSON).

, , - . 95 .

, , . , , , .

+2

, , . , (.. ).

If you force the output set to be less than the input set, you will get collisions (i.e. more input lines are β€œcompressed” for the same compressed binary string). The compression algorithm should be reversible, right? :)

+1
source

All Articles