Is there a package/function in Perl that gives me in an easy way
- a short information (e.g. a number, short string)
- like a hashvalue/checksum (e.g. MD5)
- with good distinction (e.g. cryptographic hash like MDx, SHAx)
- representing the content of a complex datastructure (e.g. hash of arrays of hashes).
Best idea I have in mind is
serialize my structure to a string (e.g. with Data::Dumper)
Hash over the string with MDx
But maybe there is some more elegant way.
In the past, I used the Data::Dumper (with sorted keys, as pointed by @mob) + Digest::MD5 approach for creating checksums of complex data structures. In my case, the purpose was to compare two or more data structures for equality.
(Very) Simple snippet:
Synopsis:
For insights about Digest algo's speed please take a look to the Digest Perl module at https://metacpan.org/pod/Digest#Digest-speed
Hope this helps