in reply to Re: Question: methods to transfer a long hexadicimal into shorter string
in thread Question: methods to transfer a long hexadicimal into shorter string
Thank everyone for the reply
Let me explain more about my project. I have 20M email listing (saved in MySQL) which we want to track in our campaigns. So instead of using original emails on the related URLs, we want to use IDs. 20-byte hexadecimal is good enough for uniqueness of 20M emails. While I am trying to find better options, i.e., if we can use shorter ID, we can significantly reduce the table size and there are more benefit from doing so...
For testing purpose, I used 3M emails and 8-byte ID and Digest::SHA1 and Convert::zBase32 to build the IDs
sub setid_1 { return undef if not $_[0]; return substr( sha1_hex(_secret_code() . $_[0]), 0, 8 ); } sub setid_2 { return undef if not $_[0]; return substr( encode_zbase32(sha1_hex(_secret_code() . $_[0])), 0 +, 8 ) }
I was hoping the second one could at least give me better uniqueness. but the result is: I got 773 duplicated IDs from setid_1 and 676131 duplicated IDs from setid_2.
Any better way to handle such issue?
thanks again
lihao
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Question: methods to transfer a long hexadicimal into shorter string
by Marshall (Canon) on Aug 07, 2009 at 23:34 UTC |