line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Code::Crypt; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Code::Crypt::VERSION = '0.001000'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Encrypt your code |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
28994
|
use Moo; |
|
1
|
|
|
|
|
29559
|
|
|
1
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5732
|
use Crypt::CBC; |
|
1
|
|
|
|
|
5671
|
|
|
1
|
|
|
|
|
44
|
|
11
|
1
|
|
|
1
|
|
1254
|
use MIME::Base64 'encode_base64'; |
|
1
|
|
|
|
|
882
|
|
|
1
|
|
|
|
|
261
|
|
12
|
|
|
|
|
|
|
has code => ( is => 'rw' ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has [qw( key get_key cipher )] => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
required => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub bootstrap { |
20
|
2
|
|
|
2
|
|
20
|
sprintf(<<'BOOTSTRAP', $_[0]->get_key, $_[0]->cipher ); |
21
|
|
|
|
|
|
|
use strict; |
22
|
|
|
|
|
|
|
use warnings; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Crypt::CBC; |
25
|
|
|
|
|
|
|
use MIME::Base64 'decode_base64'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $key = do {%s}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $cipher = Crypt::CBC->new( |
30
|
|
|
|
|
|
|
-key => $key, |
31
|
|
|
|
|
|
|
-cipher => '%s', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $ciphertext = decode_base64(<<'DATA'); |
35
|
|
|
|
|
|
|
%%sDATA |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $plain = $cipher->decrypt($ciphertext); |
38
|
|
|
|
|
|
|
local $@ = undef; |
39
|
|
|
|
|
|
|
eval($plain); |
40
|
|
|
|
|
|
|
if ($@) { |
41
|
|
|
|
|
|
|
local $_ = $@; |
42
|
|
|
|
|
|
|
if ($ENV{SHOW_CODE}) { |
43
|
|
|
|
|
|
|
require Data::Dumper::Concise; |
44
|
|
|
|
|
|
|
warn "built code was: " . Data::Dumper::Concise::Dumper($plain); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
die "This code was probably meant to run elsewhere:\n\n$_" |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
BOOTSTRAP |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub ciphercode { |
52
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
20
|
my $cipher = Crypt::CBC->new( |
55
|
|
|
|
|
|
|
-key => $self->key, |
56
|
|
|
|
|
|
|
-cipher => $self->cipher, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
4478
|
my $code = $self->code; |
60
|
2
|
|
|
|
|
9
|
return $cipher->encrypt($code) |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
2
|
1
|
9
|
sub final_code { sprintf $_[0]->bootstrap, encode_base64($_[0]->ciphercode) } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |