line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Pyzor::SHA; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright 2018 cPanel, LLC. |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
# http://cpanel.net |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the |
8
|
|
|
|
|
|
|
# Apache 2.0 license. |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
1814
|
use strict; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
119
|
|
11
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
126
|
|
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
22
|
use constant _ORDER => ( 'Digest::SHA1', 'Digest::SHA' ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1286
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $_sha_module; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _sha_module { |
18
|
6
|
100
|
|
6
|
|
14
|
if ( !$_sha_module ) { |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# First check if one of the modules is loaded. |
21
|
1
|
50
|
|
|
|
3
|
if ( my @loaded = grep { $_->can('sha1') } _ORDER ) { |
|
2
|
|
|
|
|
16
|
|
22
|
0
|
|
|
|
|
0
|
$_sha_module = $loaded[0]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
1
|
|
|
|
|
3
|
local $@; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
2
|
my @modules = _ORDER(); |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
while ( my $module = shift @modules ) { |
30
|
2
|
|
|
|
|
6
|
my $path = "$module.pm"; |
31
|
2
|
|
|
|
|
9
|
$path =~ s<::>>g; |
32
|
|
|
|
|
|
|
|
33
|
2
|
100
|
|
|
|
4
|
if ( eval { require $path; 1 } ) { |
|
2
|
50
|
|
|
|
699
|
|
|
1
|
|
|
|
|
3206
|
|
34
|
1
|
|
|
|
|
2
|
$_sha_module = $module; |
35
|
1
|
|
|
|
|
4
|
last; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( !@modules ) { |
38
|
0
|
|
|
|
|
0
|
die; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
70
|
return $_sha_module; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub sha1 { |
48
|
2
|
|
|
2
|
0
|
9
|
return _sha_module()->can('sha1')->(@_); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub sha1_hex { |
52
|
4
|
|
|
4
|
0
|
9
|
return _sha_module()->can('sha1_hex')->(@_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |