Digest::MD5

The Digest::MD5 module allows simpler creation of MD5 hashes. MD5 takes as input a message of arbitrary length and creates a 128-bit fingerprint, or digest, of the input. Like the Digest module, Digest::MD5 implements both a functional and object-oriented interface, which offer the same benefits. Digest::MD5 also outputs binary (16 bytes long), hexadecimal (32 characters long), and base64 (22 characters long) data.

To rewrite the example in Section 8.57:

#!/usr/local/bin/perl -w
# Yes, functional interface
use Digest::MD5 qw(md5_hex);

my $text = `Be the ball, Danny!';
my $hexed = md5_hex($text);
 
print "The sum of $text is [$hexed].
";

You can use the object-oriented interface like so:

#!/usr/local/bin/perl -w
 
use Digest::MD5;
 
my $text = `Be the ball, Danny!';
my $md5 = Digest::MD5->new();

$md5->add($text);
 
my $sum = $md5->hexdigest;
print "The sum of $text is [$sum].
";

Digest::MD5 implements (and exports) the following functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.83.8