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 40 $Bitcoin::Crypto::Secret::VERSION = '4.005';
3 40 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 40 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 use overload
11 40 ▶ q{""} => "as_string",
Subroutine BEGIN: called CC=1 SCAR=0.0
12 40 fallback => 1;
13  
14 40 my %secrets;
15  
16 637 ▶my $store_secret = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
17 637 my ($obj, $secret) = @_;
18  
19 637 $secrets{$obj} = $secret;
20 637 return;
21 40 };
22  
23 1793 ▶my $retrieve_secret = sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
24 1793 my ($obj) = @_;
25  
26 1793 ▶ return undef unless exists $secrets{$obj};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $secrets{$obj} 0 1793 1793
27 1793 return $secrets{$obj};
28 40 };
29  
30 637 ▶my $delete_secret = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
31 637 my ($obj) = @_;
32  
33 637 delete $secrets{$obj};
34 637 return;
35 40 };
36  
37 sub new
38 637 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
39 637 my ($class, $secret) = @_;
40  
41 637 my $str = '[REDACTED]';
42 637 my $self = bless \$str, $class;
43 637 $store_secret->(refaddr $self, $secret);
44 637 return $self;
45 }
46  
47 sub unmask_to
48 1793 ▶{
Subroutine unmask_to: called CC=1 SCAR=0.0
Pod documented
49 1793 my ($self, $sub_ref) = @_;
50  
51 1793 return $sub_ref->($retrieve_secret->(refaddr $self));
52 }
53  
54 sub DESTROY
55 637 ▶{
Subroutine DESTROY: called CC=1 SCAR=0.0
56 637 my ($self) = @_;
57  
58 637 $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 40 1;
67  
68 __END__
« Crypto/Transaction/Signer/CompatSegwit.pm ↑ Summary Crypto/Key/ExtPublic.pm »