| 1 | package SPVM::Digest::MD5; | ||
| 2 | |||
| 3 | 1 | our $VERSION = "1.009"; | |
| 4 | |||
| 5 | 1 | 1; | |
| 6 | |||
| 7 | =head1 Name | ||
| 8 | |||
| 9 | SPVM::Digest::MD5 - MD5 | ||
| 10 | |||
| 11 | =head1 Description | ||
| 12 | |||
| 13 | Digest::MD5 class in L<SPVM> calculates MD5 digest. | ||
| 14 | |||
| 15 | =head1 Usage | ||
| 16 | |||
| 17 | use Digest::MD5; | ||
| 18 | |||
| 19 | my $digest = Digest::MD5->md5($data); | ||
| 20 | my $digest_hex = Digest::MD5->md5_hex($data); | ||
| 21 | |||
| 22 | Object-Oriented Programming: | ||
| 23 | |||
| 24 | my $md5 = Digest::MD5->new; | ||
| 25 | |||
| 26 | $md5->add($data1); | ||
| 27 | $md5->add($data2); | ||
| 28 | |||
| 29 | my $digest = $md5->digest; | ||
| 30 | my $digest_hex = $md5->hexdigest; | ||
| 31 | |||
| 32 | =head1 Class Methods | ||
| 33 | |||
| 34 | =head2 md5 | ||
| 35 | |||
| 36 | C<static method md5 : string ($data : string);> | ||
| 37 | |||
| 38 | Calculates the MD5 digest | ||
| 39 | of the $data, and returns it in binary form. The returned string | ||
| 40 | will be 16 bytes long. | ||
| 41 | |||
| 42 | Exceptions: | ||
| 43 | |||
| 44 | $data must be defined. Otherwise an exception is thrown. | ||
| 45 | |||
| 46 | =head2 md5_hex | ||
| 47 | |||
| 48 | C<static method md5_hex : string ($data : string);> | ||
| 49 | |||
| 50 | Same as L</"md5">, but will return the digest in hexadecimal form. The | ||
| 51 | length of the returned string will be 32 and it will only contain | ||
| 52 | characters from this set: '0'..'9' and 'a'..'f'. | ||
| 53 | |||
| 54 | Exceptions: | ||
| 55 | |||
| 56 | Exceptions of L</"md5"> can be thrown. | ||
| 57 | |||
| 58 | =head2 new | ||
| 59 | |||
| 60 | C<static method new : L<Digest::MD5|SPVM::Digest::MD5> ();> | ||
| 61 | |||
| 62 | Returns a new L<Digest::MD5|SPVM::Digest::MD5> object which encapsulate | ||
| 63 | the state of the MD5 message-digest algorithm. | ||
| 64 | |||
| 65 | =head1 Instance Methods | ||
| 66 | |||
| 67 | =head2 add | ||
| 68 | |||
| 69 | C<method add : void ($data : string);> | ||
| 70 | |||
| 71 | $data provided as argument are appended to the message we | ||
| 72 | calculate the digest for. The return value is the L<Digest::MD5|SPVM::Digest::MD5> object itself. | ||
| 73 | |||
| 74 | Exceptions: | ||
| 75 | |||
| 76 | $data must be defined. Otherwise an exception is thrown. | ||
| 77 | |||
| 78 | Examples: | ||
| 79 | |||
| 80 | $md5->add("abc"); | ||
| 81 | $md5->add("efg"); | ||
| 82 | |||
| 83 | =head2 digest | ||
| 84 | |||
| 85 | C<method digest : string ();> | ||
| 86 | |||
| 87 | Returns the binary digest for the message. The returned string will be | ||
| 88 | 16 bytes long. | ||
| 89 | |||
| 90 | =head2 hexdigest | ||
| 91 | |||
| 92 | C<method hexdigest : string ();> | ||
| 93 | |||
| 94 | Same as L</"digest">, but will return the digest in hexadecimal | ||
| 95 | form. The length of the returned string will be 32 and it will only | ||
| 96 | contain characters from this set: '0'..'9' and 'a'..'f'. | ||
| 97 | |||
| 98 | =head1 Repository | ||
| 99 | |||
| 100 | L<SPVM::Digest::MD5 - Github|https://github.com/yuki-kimoto/SPVM-Digest-MD5> | ||
| 101 | |||
| 102 | =head1 See Also | ||
| 103 | |||
| 104 | =over 2 | ||
| 105 | |||
| 106 | =item * L<Digest::MD5> - SPVM::Digest::MD5 is a Perl's Digest::MD5 porting to SPVM | ||
| 107 | |||
| 108 | =back | ||
| 109 | |||
| 110 | =head1 Author | ||
| 111 | |||
| 112 | Yuki Kimoto C<kimoto.yuki@gmail.com> | ||
| 113 | |||
| 114 | =head1 Contributors | ||
| 115 | |||
| 116 | L<Yoshiyuki Itoh|https://github.com/YoshiyukiItoh> | ||
| 117 | |||
| 118 | =head1 Copyright & License | ||
| 119 | |||
| 120 | Copyright (c) 2023 Yuki Kimoto | ||
| 121 | |||
| 122 | MIT License |