Name
SPVM::Digest::MD5 - MD5
Description
The Digest::MD5 class of SPVM has methods for MD5.
Usage
use Digest::MD5;
my $digest = Digest::MD5->md5($data);
my $digest_hex = Digest::MD5->md5_hex($data);
Object-Oriented Programming:
my $md5 = Digest::MD5->new;
$md5->add($data1);
$md5->add($data2);
my $digest = $md5->digest;
my $digest_hex = $md5->hexdigest;
Class Methods
md5
static method md5 : string ($data : string);
Calculates the MD5 digest of the $data, and returns it in binary form. The returned string will be 16 bytes long.
Exceptions:
The $data must be defined. Otherwise an exception is thrown.
md5_hex
static method md5_hex : string ($data : string);
Same as "md5", but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: '0'..'9' and 'a'..'f'.
Exceptions:
Exceptions of "md5" can be thrown.
new
static method new : Digest::MD5 ();
Returns a new Digest::MD5 object which encapsulate the state of the MD5 message-digest algorithm.
Instance Methods
add
method add : Digest::MD5 ($data : string);
The $data provided as argument are appended to the message we calculate the digest for. The return value is the Digest::MD5 object itself.
Exceptions:
The $data must be defined. Otherwise an exception is thrown.
Examples:
$md5->add("abc");
$md5->add("efg");
digest
method digest : string ();
Returns the binary digest for the message. The returned string will be 16 bytes long.
hexdigest
method hexdigest : string ();
Same as "digest", but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: '0'..'9' and 'a'..'f'.
Repository
See Also
Digest::MD5 - SPVM::Digest::MD5 is a Perl's Digest::MD5 porting to SPVM
Author
Yuki Kimoto kimoto.yuki@gmail.com
Contributors
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License