Names to ids
David Landgren
david at landgren.net
Wed Jan 25 14:11:46 GMT 2006
Simon Wistow wrote:
> I need to turna filename into a numeric id in a repeatable manner (i.e
> the same filename must always produce the same number).
It doesn't matter if two file names map to the same number?
> My first thought (md5_hex the name and then hex the reuslt to get an
> integer) gets an overflow error unless I truncate to the first 8
> characters.
If you want all the bits to influence the outcome, then xor the 4 words
of the MD5 checksum together. Something like
my $number = 0;
$number ^= $_ for unpack 'N4', md5($filename);
should do the trick.
DAvid
> String::KoreMutake doesn't work because it can only taken certain
> phonemes.
>
> Any ideas?
>
> Simon
>
>
--
"It's overkill of course, but you can never have too much overkill."
More information about the london.pm
mailing list