In a case like this when you're teaching yourself or improving code with a known solution, it's worthwhile to go ahead and use the original code as a "check" so you can tell when you've got it right and/or wrong. Something like:
use Digest::MD5 qw(md5); my $message = ...blah blah blah...; my $md5_test = my_md5($message); my $md5_chek = md5($message); print "MESSAGE: '$message'\n" . "TEST: '$md5_test'\n" . "CHECK: '$md5_chek'\n"; print "*** MISMATCHED ***\n" unless $md5_test ne $md5_chek; sub my_md5 { ...blah blah blah... }
This way, you know you're passing the same thing to the test code and the reference code. Then you can have some confidence in your test code. (Especially if you use multiple values to verify corner cases, fencepost errors and the like.)
...roboticusIn reply to Re: MD5 -- not digest::md5
by roboticus
in thread MD5 -- not digest::md5
by Oromis92
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |