Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: How to hash a string--not data structure

by haukex (Archbishop)
on Apr 17, 2023 at 19:36 UTC ( [id://11151721]=note: print w/replies, xml ) Need Help??

in reply to How to hash a string--not data structure

Careful - there is no such thing as "a reduced-length unique string that uniquely represents the original". Unless you're talking about lossless compression, when you reduce the length of the string (i.e. "hash it"), you lose information, and there is always a small but real chance of collisions. So replace the two instances of "unique" in your sentence with "almost unique", and then your question has an answer.

It sounds to me like you are looking for Digest and one of the many algorithms such as MD5, SHA-1, SHA-256, SHA-512, etc. - Digest::MD5 and Digest::SHA are in the core. If you want a shorter checksum with a larger chance of collisions, there are also algorithms like CRC32 with corresponding modules on the CPAN.

  • Comment on Re: How to hash a string--not data structure

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-05-21 07:40 GMT
Find Nodes?
    Voting Booth?

    No recent polls found