++ a good and easy example, and a good use of & in string context,

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;

In reply to Re^2: Digest (checksum) Algorithm for 12 Decimal Digits? (32bit) by oha
in thread Digest (checksum) Algorithm for 12 Decimal Digits? by cmv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.