line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Wilkins; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
35565
|
use 5.008002; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
277
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
883
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
1
|
|
|
1
|
0
|
13
|
my $class = shift; |
11
|
1
|
|
|
|
|
5
|
my %attribs = @_; |
12
|
1
|
|
|
|
|
3
|
my $self = \%attribs; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
30
|
my %letters = ( |
15
|
|
|
|
|
|
|
a => '00001', |
16
|
|
|
|
|
|
|
b => '00010', |
17
|
|
|
|
|
|
|
c => '00011', |
18
|
|
|
|
|
|
|
d => '00100', |
19
|
|
|
|
|
|
|
e => '00101', |
20
|
|
|
|
|
|
|
f => '00110', |
21
|
|
|
|
|
|
|
g => '00111', |
22
|
|
|
|
|
|
|
h => '01000', |
23
|
|
|
|
|
|
|
i => '01001', |
24
|
|
|
|
|
|
|
j => '01010', |
25
|
|
|
|
|
|
|
k => '01011', |
26
|
|
|
|
|
|
|
l => '01100', |
27
|
|
|
|
|
|
|
m => '01101', |
28
|
|
|
|
|
|
|
n => '01110', |
29
|
|
|
|
|
|
|
o => '01111', |
30
|
|
|
|
|
|
|
p => '10000', |
31
|
|
|
|
|
|
|
q => '10001', |
32
|
|
|
|
|
|
|
r => '10010', |
33
|
|
|
|
|
|
|
s => '10011', |
34
|
|
|
|
|
|
|
t => '10100', |
35
|
|
|
|
|
|
|
u => '10101', |
36
|
|
|
|
|
|
|
v => '10110', |
37
|
|
|
|
|
|
|
w => '10111', |
38
|
|
|
|
|
|
|
x => '11000', |
39
|
|
|
|
|
|
|
y => '11001', |
40
|
|
|
|
|
|
|
z => '11010', |
41
|
|
|
|
|
|
|
'.' => '11011', |
42
|
|
|
|
|
|
|
'!' => '11100', |
43
|
|
|
|
|
|
|
'?' => '11101', |
44
|
|
|
|
|
|
|
',' => '11110', |
45
|
|
|
|
|
|
|
':' => '11111', ); |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
4
|
$self->{letters} = \%letters; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
4
|
return bless $self, $class; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub binencode { |
53
|
2
|
|
|
2
|
0
|
9
|
my $self = shift; |
54
|
2
|
|
|
|
|
3
|
my $plaintext = shift; |
55
|
2
|
|
|
|
|
4
|
my %letters = %{ $self->{letters} }; |
|
2
|
|
|
|
|
49
|
|
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
8
|
$plaintext =~ s/9/nine/g; |
58
|
2
|
|
|
|
|
3
|
$plaintext =~ s/8/eight/g; |
59
|
2
|
|
|
|
|
3
|
$plaintext =~ s/7/seven/g; |
60
|
2
|
|
|
|
|
2
|
$plaintext =~ s/6/six/g; |
61
|
2
|
|
|
|
|
4
|
$plaintext =~ s/5/five/g; |
62
|
2
|
|
|
|
|
3
|
$plaintext =~ s/4/four/g; |
63
|
2
|
|
|
|
|
3
|
$plaintext =~ s/3/three/g; |
64
|
2
|
|
|
|
|
3
|
$plaintext =~ s/2/two/g; |
65
|
2
|
|
|
|
|
3
|
$plaintext =~ s/1/one/g; |
66
|
2
|
|
|
|
|
3
|
$plaintext =~ s/0/zero/g; |
67
|
2
|
|
|
|
|
4
|
$plaintext = lc $plaintext; |
68
|
2
|
|
|
|
|
19
|
$plaintext =~ s/[^a-z\.!?,:]//g; |
69
|
2
|
|
|
|
|
58
|
$plaintext =~ s/[a-z\.!?,:]/$letters{$&}/g; |
70
|
2
|
|
|
|
|
12
|
return $plaintext; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub embed { |
75
|
1
|
|
|
1
|
0
|
339
|
my $self = shift; |
76
|
1
|
|
|
|
|
2
|
my $plaintext = shift; |
77
|
1
|
|
|
|
|
2
|
my $substrate = shift; |
78
|
|
|
|
|
|
|
# my $key = shift; |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
1
|
my $begin = $self->{tagbegin}; |
81
|
1
|
|
|
|
|
2
|
my $end = $self->{tagend}; |
82
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
3
|
my $binary = $self->binencode($plaintext); |
84
|
1
|
50
|
|
|
|
6
|
return undef unless length($binary) <= length($substrate); |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
112
|
my @substrate = split //, $substrate; |
87
|
1
|
|
|
|
|
81
|
my @binary = split //, $binary; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
8
|
my $ciphertext = ''; |
90
|
1
|
|
|
|
|
6
|
for my $i (0..$#binary){ |
91
|
215
|
|
|
|
|
449
|
while( $substrate[0] !~ /[A-Za-z0-9]/ ){ |
92
|
64
|
|
|
|
|
153
|
$ciphertext .= shift @substrate; |
93
|
|
|
|
|
|
|
} |
94
|
215
|
100
|
|
|
|
361
|
if( $binary[$i] == 1 ){ |
95
|
96
|
|
|
|
|
156
|
$ciphertext .= $begin . shift(@substrate) . $end; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
119
|
|
|
|
|
143
|
$ciphertext .= shift @substrate; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
1
|
|
|
|
|
7
|
$ciphertext .= join '', @substrate; |
102
|
1
|
|
|
|
|
17
|
return $ciphertext; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
__END__ |