line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Passphrase::SHA1::Base64; |
2
|
|
|
|
|
|
|
$Crypt::Passphrase::SHA1::Base64::VERSION = '0.015'; |
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Crypt::Passphrase -validator; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Digest::SHA 'sha1'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
9
|
1
|
|
|
1
|
|
7
|
use MIME::Base64 'decode_base64'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
202
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
2
|
|
|
2
|
1
|
324
|
my $class = shift; |
13
|
2
|
|
|
|
|
12
|
return bless {}, $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub accepts_hash { |
17
|
2
|
|
|
2
|
1
|
6
|
my ($self, $hash) = @_; |
18
|
2
|
|
|
|
|
44
|
return $hash =~ m{ ^ [A-Za-z0-9+/]{27} =? $ }x; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub verify_password { |
22
|
2
|
|
|
2
|
1
|
5
|
my ($self, $password, $hash) = @_; |
23
|
2
|
|
|
|
|
11
|
my $new_hash = sha1($password); |
24
|
2
|
|
|
|
|
13
|
return $new_hash eq decode_base64($hash); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# ABSTRACT: Validate against base64ed SHA1 hashes with Crypt::Passphrase |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |