| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Cipher; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This package is the base package for all Crypt::Ciphers, providing |
|
4
|
|
|
|
|
|
|
# an encapsulated and easily inheritable framework for building |
|
5
|
|
|
|
|
|
|
# ciphers. See the POD for more details on the user side. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# The implementation of this program is currently based on the |
|
8
|
|
|
|
|
|
|
# Regexp::Tr class and inherits from there. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Boilerplate package beginning |
|
12
|
1
|
|
|
1
|
|
26641
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
43
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
47
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
42
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
125
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Implementation-specific imports and constants |
|
18
|
1
|
|
|
1
|
|
969
|
use Regexp::Tr v0.05; |
|
|
1
|
|
|
|
|
767
|
|
|
|
1
|
|
|
|
|
95
|
|
|
19
|
|
|
|
|
|
|
use constant { |
|
20
|
1
|
|
|
|
|
194
|
UPPERCASE => join("","A".."Z"), |
|
21
|
|
|
|
|
|
|
LOWERCASE => join("","a".."z"), |
|
22
|
|
|
|
|
|
|
NUMBERS => join("",0..9) |
|
23
|
1
|
|
|
1
|
|
7
|
}; |
|
|
1
|
|
|
|
|
2
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# UNIVERSAL class variables |
|
26
|
|
|
|
|
|
|
our @ISA = qw(Regexp::Tr); |
|
27
|
|
|
|
|
|
|
our $VERSION = "1.01"; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
BEGIN { |
|
30
|
1
|
|
|
1
|
|
4
|
*clean = \&Regexp::Tr::flush; |
|
31
|
1
|
|
|
|
|
365
|
*encipher_scalar = \&Regexp::Tr::bind; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
|
35
|
1
|
|
|
1
|
1
|
21
|
my($from, $to, $mods) = @_; |
|
36
|
1
|
50
|
|
|
|
6
|
$mods .= "d" unless($mods =~ /d/); |
|
37
|
1
|
|
|
|
|
7
|
return Regexp::Tr::new($from, $to, $mods); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub encipher { |
|
41
|
4
|
|
|
4
|
1
|
1338
|
my($self,$val) = (shift,shift); |
|
42
|
4
|
|
|
|
|
14
|
Regexp::Tr::bind($self, \$val); |
|
43
|
4
|
|
|
|
|
157
|
return $val; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub encipher_string { |
|
47
|
0
|
|
|
0
|
1
|
0
|
my $obj = shift; |
|
48
|
0
|
|
|
|
|
0
|
return $obj->encipher(@_); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub encipher_list { |
|
52
|
1
|
|
|
1
|
1
|
1367
|
my $self = shift; |
|
53
|
1
|
|
|
|
|
3
|
return map { scalar($self->encipher($_)) } @_; |
|
|
3
|
|
|
|
|
8
|
|
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub encipher_array { |
|
57
|
1
|
|
|
1
|
1
|
2265
|
my($self,$ref) = @_; |
|
58
|
1
|
50
|
|
|
|
7
|
carp "Parameter passed is not an array ref" unless(ref($ref) eq "ARRAY"); |
|
59
|
1
|
|
|
|
|
2
|
my @refarray = \(@{$ref}); |
|
|
1
|
|
|
|
|
3
|
|
|
60
|
1
|
|
|
|
|
2
|
eval { map { scalar($self->encipher_scalar($_)) } @refarray }; |
|
|
1
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
62
|
|
|
61
|
1
|
50
|
|
|
|
31
|
die "Error in encipher_array: $@" if($@); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return 1; |
|
66
|
|
|
|
|
|
|
__END__ |