Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: 32bit/64bit hash function: Use perls internal hash function?

by Tux (Canon)
on Apr 08, 2022 at 09:29 UTC ( [id://11142824]=note: print w/replies, xml ) Need Help??


in reply to 32bit/64bit hash function: Use perls internal hash function?

Maybe perl's unpack is enough for you:

In addition to fields allowed in pack, you may prefix a field with a <number> to indicate that you want a <number>-bit checksum of the items instead of the items themselves. Default is a 16-bit checksum. The checksum is calculated by summing numeric values of expanded values (for string fields the sum of ord ($char) is taken; for bit fields the sum of zeroes and ones).

For example, the following computes the same number as the System V sum program:

my $checksum = do { local $/; # slurp! unpack ("%32W*", readline) % 65535; };

Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11142824]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-23 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found