Using ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 as a
characters for a base 62
i.e.
A = 1
a = 27
0 = 62
00 = 3844
000 = 238328
This should make the hex string much shorter.
1. Does anyone understand what I'm trying to do here?
2. Has this wheel already been invented?
3. Any ideas about the most efficient way to encode and decode this kind of
thing?
Thanks,
Nel
http://www.pgregg.com/projects/php/base_conversion/base_conversion.php
However, the order that is used on that for the characters are:
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
(which seems more logical than having the digits at the end)
--
Justin Koivisto, ZCE - jus...@koivi.com
http://koivi.com
If you're trying to save memory, IMHO the best way to represent your
MD5 hex string is with binary data. Check out the functions pack() to
encode to binary data, and bin2hex() to decode. Example:
<?
echo $hex_string = md5('abc123'), "\n";
$binary_data = pack('H*', $hex_string);
echo bin2hex($binary_data), "\n";
// Outputs:
// e99a18c428cb38d5f260853678922e03
// e99a18c428cb38d5f260853678922e03
?>
In this cas I am trying to pass a shorter URL and moving from base 16 to 62
knocks off about 10 chars from the URL. Not as many as I'd hoped for, but
it's a definate improvement.
Nel
Nel
You don't have to "hope", you can compute this. The number of bits per
digit is the logarithm in base 2 of the number base. Base 16 packs 4 bits
per digit. Base 62 packs 5.9 bits per digit. The string will be about 1/3
shorter.
--
- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.