module - Need some guidance on producing checksums in Perl -


i'm needing produce checksum bunch of data in perl, , came across digest::md5 module. looks fit bill, thought ask here see if has advise or possibly knows of better module use or maybe more suitable digest algorithm. what's being hashed 10 tables worth of data (one logical tuple @ time). first time make use of checksums, tips, tricks, gotchas appreciated.

edit: far know, there's nothing wrong digest:md5, i've never used nor familiar hash algorithms. hoping experience able tell me if on right track or not. wanted little bit of confirmation before going far.

yes, digest::md5 trick; it's written gisle aas (author of lwp among other excellent packages) , has good reviews & ratings on cpanratings, both of should reassure it's choice.

using can simple as:

my $checksum =  digest::md5::md5_hex($data); 

if think may change chosen digest algorithm in future (for instance, using sha-1 instead), might want consider using digest instead - written gisle aas, , providing easy interface various digest modules.

for example:

my $digest = digest->new('md5'); $digest->add($data);             # add data scalar, or: $digest->add_file($filehandle);  # add data read filehandle $checksum = $digest->hexdigest;  # or ->digest binary 

that approach has benefit change "md5" e.g. "sha-1", , you're done.

just completeness, i'll add why might want design ability use other hashing algorithms - if used security purposes, md5 has been shown vulnerable hash collisions - department of homeland security advises md5 "should considered cryptographically broken , unsuitable further use". however, general checking of data integrity, it's still acceptable choice many, , supported.

sha-1 considered weak; sha-2 considered best choice secure hashing cryptographic purposes.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -