in reply to Digest (checksum) Algorithm for 12 Decimal Digits?
Get the 39 lower bits for the MD5 of your data, convert them to a number and then to a string:
use Digest::MD5 qw(md5); my $md5 = md5($data); my $end = substr($md5, -5) & "\x7f\xff\xff\xff\xff"; my $acu = 0; $acu = $acu * 256 + ord $_ for split(//, $end); printf "%012.0f\n", $acu;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Digest (checksum) Algorithm for 12 Decimal Digits? (32bit)
by oha (Friar) on Oct 08, 2007 at 12:22 UTC | |
by salva (Canon) on Oct 08, 2007 at 14:23 UTC |