in reply to Re: Digest (checksum) Algorithm for 12 Decimal Digits?
in thread Digest (checksum) Algorithm for 12 Decimal Digits?
we must note that we have a bit more then half the possible results we could get with a 12 digit solution. (first digit will be 0..5)
also, we must note that we require 64 bit algebra.
iff we have 64 bit algebra, we could return a modulo, there is some more population on lower buckets but it's less then 0.1%, on the other hand we would have about the double of bucket, giving the OP less risks of clashing.
without 64 bit algebra, things get a little more complex:
my $md5 = ...; my $lo = 0; my $hi = 0; for(split //, $md5) { $lo = $lo*256 + ord; $hi = $hi*256 + $lo / 1_000_000; $lo = $lo % 1_000_000; $hi = $hi % 1_000_000; } return $hi.$lo;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Digest (checksum) Algorithm for 12 Decimal Digits? (32bit)
by salva (Canon) on Oct 08, 2007 at 14:23 UTC |