in reply to MD5 -- not digest::md5
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.)
...roboticus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: MD5 -- not digest::md5
by JavaFan (Canon) on Aug 15, 2009 at 17:04 UTC | |
by roboticus (Chancellor) on Aug 16, 2009 at 12:58 UTC |