blib/lib/Web/Authenticate/Digest.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 29 SCAR 6.9
CC
1
Cov
0%
generate
2.0
validate
2.0
BEGIN
2.0
CRAP 2.0
1 use strict;
2 package Web::Authenticate::Digest;
3 $Web::Authenticate::Digest::VERSION = '0.002';
4 use Mouse;
5 use Mouse::Util::TypeConstraints;
6 use Crypt::PBKDF2;
7 #ABSTRACT: The default implementation of Web::Authenticate::Digest::Role.
8  
9 with 'Web::Authenticate::Digest::Role';
10  
11  
12 has crypt => (
13 isa => 'Crypt::PBKDF2',
14 is => 'ro',
15 required => 1,
16 default => sub {
17 Crypt::PBKDF2->new(
18 hash_class => 'HMACSHA2',
19 hash_args => {
20 sha_size => 512,
21 },
22 iterations => 10000,
23 salt_len => 10,
24 );
25 },
26 );
27  
28  
29 sub generate {
30 my ($self, $password) = @_;
31 return $self->crypt->generate($password);
32 }
33  
34  
35 sub validate {
36 my ($self, $hash, $password) = @_;
37 return $self->crypt->validate($hash, $password);
38 }
39  
40 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.002
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