The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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:

$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 : void ($data : string);

$data provided as argument are appended to the message we calculate the digest for. The return value is the Digest::MD5 object itself.

Exceptions:

$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

SPVM::Digest::MD5 - Github

See Also

  • Digest::MD5 - SPVM::Digest::MD5 is a Perl's Digest::MD5 porting to SPVM

Author

Yuki Kimoto kimoto.yuki@gmail.com

Contributors

Yoshiyuki Itoh

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License