| 1 | package Digest::PBKDF2; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | 1 | ▶ | use parent "Digest::base"; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 1 | ▶ | use Crypt::PBKDF2 0.161520; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 1 | ▶ | BEGIN { | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | 1 | our $VERSION = '0.013'; # VERSION | |||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | #ABSTRACT: This module is a subclass of Digest using the Crypt::PBKDF2 algorithm. | ||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 2 | ▶ | sub new { | ||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||
| 15 | 2 | my ( $class, %params ) = @_; | |||||||||||||||||||||
| 16 | 2 | ▶ | my $encoding = $params{encoding} || 'crypt'; | ||||||||||||||||||||
|
Condition50%1/2
$params{'encoding'} || 'crypt'
MC/DC0%0/1
$params{'encoding'} || 'crypt'
$params{'encoding'}
Truth table50%1/2
A
A= $params{'encoding'}
| |||||||||||||||||||||||
| 17 | 2 | return bless { _entries => [], _data => undef, encoding => $encoding }, $class; | |||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 2 | ▶ | sub clone { | ||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 21 | 2 | my $self = shift; | |||||||||||||||||||||
| 22 | my $clone = { | ||||||||||||||||||||||
| 23 | _data => $self->{_data}, | ||||||||||||||||||||||
| 24 | _entries => $self->{_entries}, | ||||||||||||||||||||||
| 25 | encoding => $self->{encoding}, | ||||||||||||||||||||||
| 26 | 2 | }; | |||||||||||||||||||||
| 27 | 2 | return bless $clone, ref $self; | |||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | 4 | ▶ | sub add { | ||||||||||||||||||||
|
Subroutine
add: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||
| 31 | 4 | my $self = shift; | |||||||||||||||||||||
| 32 | 4 | ▶ | if (@_) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 33 | 4 | push @{ $self->{_entries} }, join '', @_; | |||||||||||||||||||||
| 34 | 4 | $self->{_data} .= join '', @_; | |||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||
| 36 | 4 | $self; | |||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||
| 38 | |||||||||||||||||||||||
| 39 | 4 | ▶ | sub reset { | ||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 40 | 4 | my $self = shift; | |||||||||||||||||||||
| 41 | 4 | delete $self->{_data}; | |||||||||||||||||||||
| 42 | 4 | delete $self->{_entries}; | |||||||||||||||||||||
| 43 | 4 | delete $self->{encoding}; | |||||||||||||||||||||
| 44 | 4 | $self; | |||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||
| 46 | |||||||||||||||||||||||
| 47 | 4 | ▶ | sub digest { | ||||||||||||||||||||
|
Subroutine
digest: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||
| 48 | 4 | my $self = shift; | |||||||||||||||||||||
| 49 | 4 | my @string = split '', $self->{_data}; | |||||||||||||||||||||
| 50 | |||||||||||||||||||||||
| 51 | 4 | my $salt; | |||||||||||||||||||||
| 52 | |||||||||||||||||||||||
| 53 | $salt = join( '', splice( @string, 0, length( $self->{_entries}->[0] ) ) ) | ||||||||||||||||||||||
| 54 | 4 | ▶ | if @{ $self->{_entries} } > 1; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 55 | 4 | my $data = join( '', @string ); | |||||||||||||||||||||
| 56 | |||||||||||||||||||||||
| 57 | 4 | ▶ | my $crypt = Crypt::PBKDF2->new( encoding => ($self->{encoding}||'ldap'), salt_len => length($salt||'') ); | ||||||||||||||||||||
|
Condition75%3/4
$self->{'encoding'} || 'ldap'
$salt || ''
MC/DC0%0/1
$self->{'encoding'} || 'ldap'
$self->{'encoding'}
MC/DC100%1/1
$salt || ''
$salt
Truth table50%1/2
A
A= $self->{'encoding'}
Truth table100%2/2
A
A= $salt
| |||||||||||||||||||||||
| 58 | 4 | my $return = $crypt->generate( $data, $salt ); | |||||||||||||||||||||
| 59 | 4 | $self->reset; | |||||||||||||||||||||
| 60 | 4 | $return; | |||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||
| 62 | |||||||||||||||||||||||
| 63 | 1 | 1; | |||||||||||||||||||||
| 64 | |||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||