Licence.pm

filter: Statementstmt 96.2% 51 / 53 Branchbran 33.3% 2 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 15 / 15 Podpod 0.0% 0 / 7 totaltotal 80.2% 69 / 86 SCAR 16.2
CC
5
Cov
87%
new
6.9
BEGIN
1.0
BEGIN
1.0
CRAP 5.1
« Licence/Validate.pm ↑ Summary Licence/Generate.pm »
1 package Enterprise::Licence;
2 2 ▶our $VERSION = '0.01'; use utf8; use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use DateTime; use Math::BigInt; use Compress::Huffman;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Shannon::Entropy qw/entropy/; use Bijection qw/all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub new {
7 4 ▶ my ($pkg, $args) = (@_, {});
Subroutine new: called CC=5 SCAR=19.3
Pod undocumented
8 4 my $self = bless {}, $pkg;
9 4 ▶ unless ($args->{secret} && entropy($args->{secret}) > 3) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->{"secret"} and entropy($args->{"secret"}) > 3) 0 4 4
Condition33%1/3
$args->{"secret"} and entropy($args->{"secret"}) > 3
!ll&&!rl&&r
004
MC/DC0%0/2
$args->{"secret"} and entropy($args->{"secret"}) > 3
$args->{"secret"} entropy($args->{"secret"}) > 3
Truth table33%1/3
A and B
A= $args->{"secret"}B= entropy($args->{"secret"}) > 3
ABresult
0X0
100
111
10 0 die 'no secure secret passed to new';
11 }
12 4 $self->{secret} = $args->{secret};
13 4 my $ch = huffman([split '', $args->{secret}]);
14 4 $self->{ch} = $ch;
15 bijection_set(
16 ($args->{offset} ? $args->{offset} : ()),
17 0 @{$args->{biject}}
18 4 ▶ ) if $args->{biject};
Branch: 2 branches
BranchTrueFalseTotal
if $args->{"biject"} 0 4 4
$args->{'offset'} ? : 0 0 0
19 4 $self;
20 }
21  
22 sub bin2dec {
23 6 ▶ my $dec = $_[1];
Subroutine bin2dec: called CC=1 SCAR=0.0
Pod undocumented
24 6 return Math::BigInt->new("0b$dec");
25 }
26  
27 sub dec2bin {
28 2 ▶ my $i = Math::BigInt->new($_[1]);
Subroutine dec2bin: called CC=1 SCAR=0.0
Pod undocumented
29 2 return substr($i->as_bin(), 2);
30 }
31  
32 sub customer_offset {
33 4 ▶ my $encode = [split '', $_[1]];
Subroutine customer_offset: called CC=1 SCAR=0.0
Pod undocumented
34 4 my $ch = huffman($encode);
35 4 return $ch->encode($encode);
36 }
37  
38 sub huffman {
39 8 ▶ my $encode = shift;
Subroutine huffman: called CC=1 SCAR=0.0
Pod undocumented
40 8 my $ch = Compress::Huffman->new();
41 8 my $i = 0.1;
42 my %symbols = map {
43 68 $_ => ( $i += 0.1 )
44 8 } @{$encode};
45 8 $ch->symbols(\%symbols, notprob => 1);
46 8 return $ch;
47 }
48  
49 8 ▶sub bi { return scalar biject($_[1]); }
Subroutine bi: called CC=1 SCAR=0.0
Pod undocumented
50 8 ▶sub in { return scalar inverse($_[1]); }
Subroutine in: called CC=1 SCAR=0.0
Pod undocumented
51  
52 2 1;
53  
54 __END__
55  
56 =head1 NAME
57  
58 Enterprise::Licence - The great new Enterprise::Licence!
59  
60 =head1 VERSION
61  
62 Version 0.01
63  
64 =cut
65  
66 =head1 SYNOPSIS
67  
68 use Enterprise::Licence::Generate;
69 use Enterprise::Licence::Validate;
70  
71 my $sec = 'IAmLimited';
72 my $generator = Enterprise::Licence::Generate->new({ secret => $sec });
73  
74 my $client = 'unique';
75 my $licence = $generator->generate($client, { years => 99 });
76  
77 my $validator = Enterprise::Licence::Validate->new({ secret => $sec });
78 my @valid = $validator->valid($licence, $client);
79 # (1) == valid
80 # (0, 1) == expired
81 # (0, 0) == invalid
82  
83 =cut
84  
85 =head1 AUTHOR
86  
87 LNATION, C<< <thisusedtobeanemail at gmail.com> >>
88  
89 =head1 BUGS
90  
91 Please report any bugs or feature requests to C<bug-enterprise-licence at rt.cpan.org>, or through
92 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Enterprise-Licence>. I will be notified, and then you'll
93 automatically be notified of progress on your bug as I make changes.
94  
95 =head1 SUPPORT
96  
97 You can find documentation for this module with the perldoc command.
98  
99 perldoc Enterprise::Licence
100  
101  
102 You can also look for information at:
103  
104 =over 4
105  
106 =item * RT: CPAN's request tracker (report bugs here)
107  
108 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Enterprise-Licence>
109  
110 =item * AnnoCPAN: Annotated CPAN documentation
111  
112 L<http://annocpan.org/dist/Enterprise-Licence>
113  
114 =item * CPAN Ratings
115  
116 L<http://cpanratings.perl.org/d/Enterprise-Licence>
117  
118 =item * Search CPAN
119  
120 L<http://search.cpan.org/dist/Enterprise-Licence/>
121  
122 =back
123  
124  
125 =head1 ACKNOWLEDGEMENTS
126  
127  
128 =head1 LICENSE AND COPYRIGHT
129  
130 Copyright 2019 LNATION.
131  
132 This program is free software; you can redistribute it and/or modify it
133 under the terms of the the Artistic License (2.0). You may obtain a
134 copy of the full license at:
135  
136 L<http://www.perlfoundation.org/artistic_license_2_0>
137  
138 Any use, modification, and distribution of the Standard or Modified
139 Versions is governed by this Artistic License. By using, modifying or
140 distributing the Package, you accept this license. Do not use, modify,
141 or distribute the Package, if you do not accept this license.
142  
143 If your Modified Version has been derived from a Modified Version made
144 by someone other than you, you are nevertheless required to ensure that
145 your Modified Version complies with the requirements of this license.
146  
147 This license does not grant you the right to use any trademark, service
148 mark, tradename, or logo of the Copyright Holder.
149  
150 This license includes the non-exclusive, worldwide, free-of-charge
151 patent license to make, have made, use, offer to sell, sell, import and
152 otherwise transfer the Package with respect to any patent claims
153 licensable by the Copyright Holder that are necessarily infringed by the
154 Package. If you institute patent litigation (including a cross-claim or
155 counterclaim) against any party alleging that the Package constitutes
156 direct or contributory patent infringement, then this Artistic License
157 to you shall terminate on the date that such litigation is filed.
158  
159 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
160 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
161 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
162 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
163 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
164 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
165 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
166 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
167  
168  
169 =cut
170  
171 1; # End of Enterprise::Licence
« Licence/Validate.pm ↑ Summary Licence/Generate.pm »