Apache-LoggedAuthDBI
view release on metacpan or search on metacpan
message we calculate the digest for. The return value is the $md5
object itself.
The addfile() method will croak() if it fails reading data for some
reason. If it croaks it is unpredictable what the state of the $md5
object will be in. The addfile() method might have been able to read
the file partially before it failed. It is probably wise to discard
or reset the $md5 object if this occurs.
In most cases you want to make sure that the $io_handle is in
C<binmode> before you pass it as argument to the addfile() method.
=item $md5->add_bits($data, $nbits)
=item $md5->add_bits($bitstring)
Since the MD5 algorithm is byte oriented you might only add bits as
multiples of 8, so you probably want to just use add() instead. The
add_bits() method is provided for compatibility with other digest
implementations. See L<Digest> for description of the arguments
that add_bits() take.
With OO style you can break the message arbitrary. This means that we
are no longer limited to have space for the whole message in memory, i.e.
we can handle messages of any size.
This is useful when calculating checksum for files:
use Digest::MD5;
my $file = shift || "/etc/passwd";
open(FILE, $file) or die "Can't open '$file': $!";
binmode(FILE);
$md5 = Digest::MD5->new;
while (<FILE>) {
$md5->add($_);
}
close(FILE);
print $md5->b64digest, " $file\n";
Or we can use the addfile method for more efficient reading of
the file:
use Digest::MD5;
my $file = shift || "/etc/passwd";
open(FILE, $file) or die "Can't open '$file': $!";
binmode(FILE);
print Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\n";
Perl 5.8 support Unicode characters in strings. Since the MD5
algorithm is only defined for strings of bytes, it can not be used on
strings that contains chars with ordinal number above 255. The MD5
functions and methods will croak if you try to feed them such input
data:
use Digest::MD5 qw(md5_hex);
message we calculate the digest for. The return value is the $sha1
object itself.
The addfile() method will croak() if it fails reading data for some
reason. If it croaks it is unpredictable what the state of the $sha1
object will be in. The addfile() method might have been able to read
the file partially before it failed. It is probably wise to discard
or reset the $sha1 object if this occurs.
In most cases you want to make sure that the $io_handle is in
C<binmode> before you pass it as argument to the addfile() method.
=item $sha1->add_bits($data, $nbits)
=item $sha1->add_bits($bitstring)
This implementation of SHA-1 only supports byte oriented input so you
might only add bits as multiples of 8. If you need bit level support
please consider using the C<Digest::SHA> module instead. The
add_bits() method is provided here for compatibility with other digest
implementations. See L<Digest> for description of the arguments that
( run in 0.513 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )