line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=pod
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Crypt::Mimetic::None - No Encryption
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This module is a part of I.
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This modules does not encrypt anything: it only do a bitwise negation. I needs @info containing generic-blocks-length and last-block-length (padlen). I and I return the bitwise negated string.
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Crypt::Mimetic::None;
|
17
|
1
|
|
|
1
|
|
7
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
18
|
1
|
|
|
1
|
|
7
|
use Error::Mimetic;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
19
|
1
|
|
|
1
|
|
151
|
use vars qw($VERSION);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1017
|
|
20
|
|
|
|
|
|
|
$VERSION = '0.01';
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=pod
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 PROCEDURAL INTERFACE
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item string I ()
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Return a short description of algorithm
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub ShortDescr {
|
33
|
1
|
|
|
1
|
1
|
5
|
return "None - Special algorithm to not encrypt; very fast.";
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=pod
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item boolean I ()
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Return true if password is needed by this algorithm, false otherwise.
|
41
|
|
|
|
|
|
|
('None' return always false)
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub PasswdNeeded {
|
46
|
0
|
|
|
0
|
1
|
0
|
return 0;
|
47
|
|
|
|
|
|
|
}
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=pod
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item ($len,$blocklen,$padlen,[string]) I ($filename,$output,$algorithm,$key,@info)
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Do a bitwise negation of $filename. See I.
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub EncryptFile {
|
58
|
0
|
|
|
0
|
1
|
0
|
my ($filename,$output,$algorithm,$key,@info) = @_;
|
59
|
0
|
|
|
|
|
0
|
my ($buf, $text, $txt) = ("","","");
|
60
|
0
|
|
|
|
|
0
|
my ($len,$blocklen,$padlen) = (0,0,0);
|
61
|
0
|
0
|
|
|
|
0
|
if ($output) {
|
62
|
0
|
0
|
|
|
|
0
|
open(OUT,">>$output") or throw Error::Mimetic "Cannot open $output: $!";
|
63
|
|
|
|
|
|
|
}
|
64
|
0
|
0
|
|
|
|
0
|
open(IN,"$filename") or throw Error::Mimetic "Cannot open $filename: $!";
|
65
|
0
|
|
|
|
|
0
|
while ( read(IN,$buf,32768) ) {
|
66
|
0
|
|
|
|
|
0
|
$blocklen = $padlen;
|
67
|
0
|
|
|
|
|
0
|
$text = ~$buf;
|
68
|
0
|
|
|
|
|
0
|
$padlen = length($text);
|
69
|
0
|
|
|
|
|
0
|
$len += $padlen;
|
70
|
0
|
0
|
|
|
|
0
|
if ($output) {
|
71
|
0
|
|
|
|
|
0
|
print OUT $text;
|
72
|
|
|
|
|
|
|
} else {
|
73
|
0
|
|
|
|
|
0
|
$txt .= $text;
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
}
|
76
|
0
|
|
|
|
|
0
|
close(IN);
|
77
|
0
|
0
|
|
|
|
0
|
if ($output) {
|
78
|
0
|
|
|
|
|
0
|
close(OUT);
|
79
|
0
|
|
|
|
|
0
|
return ($len,$blocklen,$padlen);
|
80
|
|
|
|
|
|
|
}
|
81
|
0
|
|
|
|
|
0
|
return ($len,$blocklen,$padlen,$txt);
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item string I ($string,$algorithm,$key,@info)
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Do a bitwise negation of $string. See I.
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub EncryptString {
|
93
|
1
|
|
|
1
|
1
|
3
|
my ($string,$algorithm,$key,@info) = @_;
|
94
|
1
|
|
|
|
|
6
|
return ~$string;
|
95
|
|
|
|
|
|
|
}
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=pod
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item [string] I ($filename,$output,$offset,$len,$algorithm,$key,@info)
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Do a bitwise negation of $filename. See I.
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub DecryptFile {
|
106
|
0
|
|
|
0
|
1
|
0
|
my ($filename,$output,$offset,$len,$algorithm,$key,@info) = @_;
|
107
|
0
|
|
|
|
|
0
|
my ($blocklen,$padlen) = @info;
|
108
|
0
|
|
|
|
|
0
|
my ($buf, $text, $i, $txt) = ("","",0,"");
|
109
|
0
|
0
|
|
|
|
0
|
$blocklen = 32768 unless $blocklen;
|
110
|
0
|
|
|
|
|
0
|
my $blocks = 0;
|
111
|
0
|
0
|
|
|
|
0
|
$blocks = int($len/$blocklen) if $blocklen;
|
112
|
0
|
0
|
|
|
|
0
|
if ($output) {
|
113
|
0
|
0
|
|
|
|
0
|
open(OUT,">$output") or throw Error::Mimetic "Cannot open $output: $!";
|
114
|
|
|
|
|
|
|
}
|
115
|
0
|
0
|
|
|
|
0
|
open(IN,"$filename") or throw Error::Mimetic "Cannot open $filename: $!";
|
116
|
0
|
|
|
|
|
0
|
seek IN, $offset, 0;
|
117
|
0
|
|
|
|
|
0
|
for ($i = 0; $i < $blocks; $i++ ) {
|
118
|
0
|
|
|
|
|
0
|
read(IN,$buf,$blocklen);
|
119
|
0
|
|
|
|
|
0
|
$text = ~$buf;
|
120
|
0
|
0
|
|
|
|
0
|
if ($output) {
|
121
|
0
|
|
|
|
|
0
|
print OUT $text;
|
122
|
|
|
|
|
|
|
} else {
|
123
|
0
|
|
|
|
|
0
|
$txt .= $text;
|
124
|
|
|
|
|
|
|
}
|
125
|
|
|
|
|
|
|
}
|
126
|
0
|
|
|
|
|
0
|
read(IN,$buf,$padlen);
|
127
|
0
|
|
|
|
|
0
|
$text = ~$buf;
|
128
|
0
|
0
|
|
|
|
0
|
if ($output) {
|
129
|
0
|
|
|
|
|
0
|
print OUT $text;
|
130
|
|
|
|
|
|
|
} else {
|
131
|
0
|
|
|
|
|
0
|
$txt .= $text;
|
132
|
|
|
|
|
|
|
}
|
133
|
0
|
|
|
|
|
0
|
close(IN);
|
134
|
0
|
0
|
|
|
|
0
|
if ($output) {
|
135
|
0
|
|
|
|
|
0
|
close(OUT);
|
136
|
|
|
|
|
|
|
} else {
|
137
|
0
|
|
|
|
|
0
|
return $txt;
|
138
|
|
|
|
|
|
|
}
|
139
|
|
|
|
|
|
|
}
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=pod
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item string I ($string,$algorithm,$key,@info)
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Do a bitwise negation of $string. See I.
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub DecryptString {
|
150
|
1
|
|
|
1
|
1
|
2
|
my ($string,$algorithm,$key,@info) = @_;
|
151
|
1
|
|
|
|
|
5
|
return ~$string;
|
152
|
|
|
|
|
|
|
}
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1;
|
155
|
|
|
|
|
|
|
__END__
|