line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Types::Digest; |
2
|
2
|
|
|
2
|
|
23047
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
893
|
use Type::Library -base, -declare => qw(Md5 Sha1 Sha224 Sha256 Sha384 Sha512); |
|
2
|
|
|
|
|
29001
|
|
|
2
|
|
|
|
|
17
|
|
8
|
2
|
|
|
2
|
|
3721
|
use Types::Standard qw(Str); |
|
2
|
|
|
|
|
52858
|
|
|
2
|
|
|
|
|
13
|
|
9
|
2
|
|
|
2
|
|
1798
|
use Type::Utils; |
|
2
|
|
|
|
|
6300
|
|
|
2
|
|
|
|
|
15
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Types::Digest - digests types for Moose and Moo |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Foo; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Moose; |
20
|
|
|
|
|
|
|
use Types::Digest qw/Sha256/; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has md5 => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => Md5, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has sha256 => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => Sha256, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This module provides common digests types for Moose, Moo, etc. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SUBTYPES |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 Md5 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
L |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 Sha1 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
L |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 Sha224 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 Sha256 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 Sha384 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
L |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 Sha512 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
L |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
_declare_digest('Md5', 32); |
66
|
|
|
|
|
|
|
_declare_digest('Sha1', 40); |
67
|
|
|
|
|
|
|
_declare_digest('Sha224', 56); |
68
|
|
|
|
|
|
|
_declare_digest('Sha256', 64); |
69
|
|
|
|
|
|
|
_declare_digest('Sha384', 96); |
70
|
|
|
|
|
|
|
_declare_digest('Sha512', 128); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _declare_digest { |
73
|
12
|
|
|
12
|
|
17
|
my ($name, $len) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
declare $name, |
76
|
36
|
|
|
36
|
|
17261
|
as Str, where { /[a-f0-9]{$len}/i }, |
77
|
12
|
|
|
12
|
|
22
|
message { "Must be $len chars, and contain only [0-9a-fA-F]" }; |
|
12
|
|
|
|
|
2372
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SEE ALSO |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
this module is inspired by L |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 LICENSE |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Copyright (C) Avast Software. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
89
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Jan Seidl Eseidl@avast.comE |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |