Crypto/Secret.pm

filter: Statementstmt 100% 40 / 40 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 3 / 3 totaltotal 98.2% 56 / 57 CC 2 SCAR 1.5
CC
2
Cov
98%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Crypto/Transaction/Signer/CompatSegwit.pm ↑ Summary Crypto/Key/ExtPublic.pm »
1 package Bitcoin::Crypto::Secret;
2 43 $Bitcoin::Crypto::Secret::VERSION = '4.006';
3 43 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 43 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 43 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 43 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 use overload
11 43 ▶ q{""} => "as_string",
Subroutine BEGIN: called CC=1 SCAR=0.0
12 43 fallback => 1;
13  
14 43 my %secrets;
15  
16 667 ▶my $store_secret = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
17 667 my ($obj, $secret) = @_;
18  
19 667 $secrets{$obj} = $secret;
20 667 return;
21 43 };
22  
23 1981 ▶my $retrieve_secret = sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
24 1981 my ($obj) = @_;
25  
26 1981 ▶ return undef unless exists $secrets{$obj};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $secrets{$obj} 0 1981 1981
27 1981 return $secrets{$obj};
28 43 };
29  
30 667 ▶my $delete_secret = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
31 667 my ($obj) = @_;
32  
33 667 delete $secrets{$obj};
34 667 return;
35 43 };
36  
37 sub new
38 667 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
39 667 my ($class, $secret) = @_;
40  
41 667 my $str = '[REDACTED]';
42 667 my $self = bless \$str, $class;
43 667 $store_secret->(refaddr $self, $secret);
44 667 return $self;
45 }
46  
47 sub unmask_to
48 1981 ▶{
Subroutine unmask_to: called CC=1 SCAR=0.0
Pod documented
49 1981 my ($self, $sub_ref) = @_;
50  
51 1981 return $sub_ref->($retrieve_secret->(refaddr $self));
52 }
53  
54 sub DESTROY
55 667 ▶{
Subroutine DESTROY: called CC=1 SCAR=0.0
56 667 my ($self) = @_;
57  
58 667 $delete_secret->(refaddr $self);
59 }
60  
61 sub as_string
62 3 ▶{
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
63 3 return ${$_[0]};
64 }
65  
66 43 1;
67  
68 __END__
« Crypto/Transaction/Signer/CompatSegwit.pm ↑ Summary Crypto/Key/ExtPublic.pm »