line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Passphrase::SHA1::Base64; |
2
|
|
|
|
|
|
|
$Crypt::Passphrase::SHA1::Base64::VERSION = '0.016'; |
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Crypt::Passphrase -validator; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Digest::SHA 'sha1'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
9
|
1
|
|
|
1
|
|
6
|
use MIME::Base64 'decode_base64'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
221
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
2
|
|
|
2
|
1
|
303
|
my $class = shift; |
13
|
2
|
|
|
|
|
10
|
return bless {}, $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub accepts_hash { |
17
|
2
|
|
|
2
|
1
|
6
|
my ($self, $hash) = @_; |
18
|
2
|
|
|
|
|
11
|
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
|
|
|
|
|
12
|
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__ |