Challenge:
I was given a scenario in which i need to represent a large number by few character it must be hard to break the code.
For ex: A 8 digit number into 5-6 character. That too uniquely identified per number (i.e code corresponding to each number should not match the code corresponding to different number)
Solution: How we take a binary form of 78542 We keep dividing the number by 2 and noting down the remainders like the binary form of 78542 will be 11001011001110 .
This is just like representing 78542 to 0 and 1 character representation.
This is called base 2 representation (78542)10 = (1001011001110)2
Now,
What if we follow the same process by changing few things Changes:- previously we are diving it with 2 now we make 38
change the representing character from only 0 and 1 to “abcdefghijklmnopqrstuvwxyz0123456789$%” (i.e if the remainder is 1 then we use character “a” , for 2 we use “b” and so on ).
so the representation that we get for number 78542 is (n57v)38
by following the above procedure.
So we are done with the changes for representing in to less character
Note: the number of character which is used to represent 78542 is 4. If we apply Permutation to find out the range of this character is 38 X 38 X 38 X 38 = 2085136. (i.e we can represent any number between 0 to 2085136 uniquely .
Till now we are representing all the remainders with a single set of character (i.e “abcdefghijklmnopqrstuvwxyz0123456789$%”)
If we use different set of character for different places of remainders, like for first remainder we use “abcdefghijklmnopqrstuvwxyz0123456789$%” , for second one we use “abcdefghijkl$&#mnopqrstuvwxyz5863190427” , for third one we use “$nt#07sbpfgh91widxqrze&yvaj683klumco245” , For fourth one “076$83swint#dxqrze&yvajklumcobpfgh91245”
Then the representation for 78542 will be “9#d7”
Till now this was a serial generation still this can be easily reverse engineered the process When set of code is given in serial order.
So what next.
I thought of Changing the arrangement of the Character obviously ,not randomly but in a specific order (like “9#d7” is changed to “d#97”)
So how we will distinguish in which order the code is given? For that we add a character into it which we call it “identifier” . Now this identifier will determine the order in which the code is arranged (Ex: 9#d7 is arranged to d#97 in case , first character is shifted to 3rd place , 2nd one remains at same position, 3rd one is shifted to 1st and last one remains at last . For this arrangement we take an identifier as “g” and insert this into the third place now my code will look like this “d#g97” ) .
In this process the identifier place must not be changed . If we place identifier to 3rd place then through out the code generation it will be on the third place. This identifier will make this code unique till the end of the limit.
So how will we use this identifier effectively?
Remember we are thinking of serial order generation . On every next value calculation we will change the order of the code and mark it with identifier . (For Ex: for 78542 we used identifier “g” for next value 78543 we use identifier “q” and Change the order to 1st to 2nd , 2nd to 1st , 3rd to 4th and 4th to 3rd )
Now we inserted one more character , so the limit will also increase . The new formula will be
New Limit = previous limit * number of identifier used
In case , previous limit = 2085136
number of identifier used = 2
New Limit = 2085136 * 2
Example code For Filemaker People,
Let ( [ charset1 =”qwertyuiopasdfghjklzxcvbnm$�″;
charset2 =”abcdefghijkl$&#mnopqrstuvwxyz5863190427″;
charset3 =”$nt#07sbpfgh91widxqrze&yvaj683klumco245″;
charset4 =”076$83swint#dxqrze&yvajklumcobpfgh91245″;
code1 = Mod ( Number ; 38 ) + 1;
code2 = Mod ( Div ( Number ; 38 ) ; 38 ) + 1;
code3 = Mod ( Div ( Number ; 38 * 38 ) ; 38 ) + 1;
code4 = Mod ( Div ( Number ; 38 * 38 * 38 ) ; 38 ) + 1;
code5 = Mod ( Div ( Number ; 38 * 38 * 38 * 38 ) ; 38 ) + 1;
main =”$95stv#”;
Kpid = Number
] ;
Case ( Mod ( Kpid ; 7 ) = 0 ; Middle ( charset1 ; code1 ; 1 ) & Middle ( charset2 ; code2 ; 1 ) & “$” & Middle ( charset3 ; code3 ; 1 ) & Middle ( charset4 ; code4 ; 1 ) & Middle ( charset3 ; code5 ; 1 ) ;
Mod ( Kpid ; 7 ) = 1 ; Middle ( charset1 ; code2 ; 1 ) & Middle ( charset2 ; code4 ; 1 ) & “9” & Middle ( charset3 ; code1 ; 1 ) & Middle ( charset4 ; code5 ; 1 ) & Middle ( charset3 ; code3 ; 1 ) ;
Mod ( Kpid ; 7 ) = 2 ; Middle ( charset1 ; code5 ; 1 ) & Middle ( charset2 ; code1 ; 1 ) & “5” & Middle ( charset3 ; code2 ; 1 ) & Middle ( charset4 ; code3 ; 1 ) & Middle ( charset3 ; code4 ; 1 ) ;
Mod ( Kpid ; 7 ) = 3 ; Middle ( charset1 ; code3 ; 1 ) & Middle ( charset2 ; code5 ; 1 ) & “s” & Middle ( charset3 ; code4 ; 1 ) & Middle ( charset4 ; code1 ; 1 ) & Middle ( charset3 ; code2 ; 1 ) ;
Mod ( Kpid ; 7 ) = 4 ; Middle ( charset1 ; code4 ; 1 ) & Middle ( charset2 ; code3 ; 1 ) & “t” & Middle ( charset3 ; code5 ; 1 ) & Middle ( charset4 ; code2 ; 1 ) & Middle ( charset3 ; code1 ; 1 ) ;
Mod ( Kpid ; 7 ) = 5 ; Middle ( charset1 ; code4 ; 1 ) & Middle ( charset2 ; code2 ; 1 ) & “v” & Middle ( charset3 ; code1 ; 1 ) & Middle ( charset4 ; code3 ; 1 ) & Middle ( charset3 ; code5 ; 1 ) ;
Mod ( Kpid ; 7 ) = 6 ; Middle ( charset1 ; code5 ; 1 ) & Middle ( charset2 ; code4 ; 1 ) & “#” & Middle ( charset3 ; code3 ; 1 ) & Middle ( charset4 ; code1 ; 1 ) & Middle ( charset3 ; code2 ; 1 ) ;
) )
Application:
For Coupon Code generation
UniqueId for people.