lib/Web/Authenticate/Digest.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 50.0% 1 / 2 totaltotal 86.6% 26 / 30 CC 1 SCAR 1.3
CC
1
Cov
90%
validate
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/Web/storage.pl ↑ Summary lib/Web/Authenticate/Digest/Role.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Web::Authenticate::Digest;
3 1 $Web::Authenticate::Digest::VERSION = '0.003';
4 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Mouse::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Crypt::PBKDF2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 #ABSTRACT: The default implementation of Web::Authenticate::Digest::Role.
8  
9 1 with 'Web::Authenticate::Digest::Role';
10  
11  
12 has crypt => (
13 isa => 'Crypt::PBKDF2',
14 is => 'ro',
15 required => 1,
16 default => sub {
17 1 ▶ Crypt::PBKDF2->new(
Subroutine __ANON__: called CC=1 SCAR=0.0
18 hash_class => 'HMACSHA2',
19 hash_args => {
20 sha_size => 512,
21 },
22 iterations => 10000,
23 salt_len => 10,
24 );
25 },
26 1 );
27  
28  
29 sub generate {
30 1 ▶ my ($self, $password) = @_;
Subroutine generate: called CC=1 SCAR=0.0
Pod documented
31 1 return $self->crypt->generate($password);
32 }
33  
34  
35 sub validate {
36 0 ▶ my ($self, $hash, $password) = @_;
Subroutine validate: not called CC=1 SCAR=6.9
Pod undocumented
37 0 return $self->crypt->validate($hash, $password);
38 }
39  
40 1 1;
41  
42 __END__
43  
44 =pod
45  
46 =encoding UTF-8
47  
48 =head1 NAME
49  
50 Web::Authenticate::Digest - The default implementation of Web::Authenticate::Digest::Role.
51  
52 =head1 VERSION
53  
54 version 0.003
55  
56 =head1 METHODS
57  
58 =head2 crypt
59  
60 Sets the L<Crypt::PBKDF2> object that is used to create and validate digests. Below is the default:
61  
62 Crypt::PBKDF2->new(
63 hash_class => 'HMACSHA2',
64 hash_args => {
65 sha_size => 512,
66 },
67 iterations => 10000,
68 salt_len => 10,
69 )
70  
71 =head2 generate
72  
73 Accepts a password and returns the hex digest of that password using L</crypt>.
74  
75 my $password_digest = $digest->generate($password);
76  
77 =head2
78  
79 Uses L<Crypt::PBKDF2/"validate">.
80  
81 my $validate_success = $digest->validate($hash, $password);
82  
83 =head1 AUTHOR
84  
85 Adam Hopkins <srchulo@cpan.org>
86  
87 =head1 COPYRIGHT AND LICENSE
88  
89 This software is copyright (c) 2017 by Adam Hopkins.
90  
91 This is free software; you can redistribute it and/or modify it under
92 the same terms as the Perl 5 programming language system itself.
93  
94 =cut
« blib/lib/Web/storage.pl ↑ Summary lib/Web/Authenticate/Digest/Role.pm »