| 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 | # same terms as Perl itself. See L<perlartistic>. | ||||||||||||||
| 9 | |||||||||||||||
| 10 | 4 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 4 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 4 | ▶ | use constant _ORDER => ( 'Digest::SHA1', 'Digest::SHA' ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | 4 | my $_sha_module; | |||||||||||||
| 16 | |||||||||||||||
| 17 | sub _sha_module { | ||||||||||||||
| 18 | 6 | ▶ | if ( !$_sha_module ) { | ||||||||||||
|
Subroutine
_sha_module: called CC=6 SCAR=19.0
Branch: 1 branch
| |||||||||||||||
| 19 | |||||||||||||||
| 20 | # First check if one of the modules is loaded. | ||||||||||||||
| 21 | 1 | ▶ | if ( my @loaded = grep { $_->can('sha1') } _ORDER ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 22 | 0 | $_sha_module = $loaded[0]; | |||||||||||||
| 23 | } | ||||||||||||||
| 24 | else { | ||||||||||||||
| 25 | 1 | local $@; | |||||||||||||
| 26 | |||||||||||||||
| 27 | 1 | my @modules = _ORDER(); | |||||||||||||
| 28 | |||||||||||||||
| 29 | 1 | ▶ | while ( my $module = shift @modules ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 30 | 1 | my $path = "$module.pm"; | |||||||||||||
| 31 | 1 | $path =~ s<::></>g; | |||||||||||||
| 32 | |||||||||||||||
| 33 | 1 | ▶ | if ( eval { require $path; 1 } ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 34 | 1 | $_sha_module = $module; | |||||||||||||
| 35 | 1 | last; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | elsif ( !@modules ) { | ||||||||||||||
| 38 | 0 | die; | |||||||||||||
| 39 | } | ||||||||||||||
| 40 | } | ||||||||||||||
| 41 | } | ||||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 6 | return $_sha_module; | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | sub sha1 { | ||||||||||||||
| 48 | 2 | ▶ | return _sha_module()->can('sha1')->(@_); | ||||||||||||
|
Subroutine
sha1: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | sub sha1_hex { | ||||||||||||||
| 52 | 4 | ▶ | return _sha_module()->can('sha1_hex')->(@_); | ||||||||||||
|
Subroutine
sha1_hex: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 53 | } | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 4 | 1; | |||||||||||||