line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# package: Anak Cryptography with Fractal Numerical Algorithm FNA
|
2
|
|
|
|
|
|
|
# author: Mario Rossano aka Anak, www.netlogicalab.com, www.netlogica.it; software@netlogicalab.com; software@netlogica.it
|
3
|
|
|
|
|
|
|
# birthday 05/08/1970; birthplace: Italy
|
4
|
|
|
|
|
|
|
# LIBRARY FILE
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Copyright (C) 2009,2010 Mario Rossano aka Anak
|
7
|
|
|
|
|
|
|
#
|
8
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
9
|
|
|
|
|
|
|
# under the terms of either:
|
10
|
|
|
|
|
|
|
# CC-NC-BY-SA
|
11
|
|
|
|
|
|
|
# license http://creativecommons.org/licenses/by-nc-sa/2.5/it/deed.en
|
12
|
|
|
|
|
|
|
# Creative Commons License: http://i.creativecommons.org/l/by-nc-sa/2.5/it/88x31.png
|
13
|
|
|
|
|
|
|
# FNA Fractal Numerical Algorithm for a new cryptography technology, author Mario Rossano
|
14
|
|
|
|
|
|
|
# is licensed under a: http://creativecommons.org/B/by-nc-sa/2.5/it/deed.en - Creative Commons Attribution-Noncommercial-Share Alike 2.5 Italy License
|
15
|
|
|
|
|
|
|
# Permissions beyond the scope of this license may be available at software@netlogicalab.com
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Crypt::FNA::Async;
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# caricamento lib
|
20
|
2
|
|
|
2
|
|
64378
|
use strict;
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
104
|
|
21
|
2
|
|
|
2
|
|
12
|
use warnings;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2815
|
|
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
20934
|
our $can_use_FNA = eval 'use Crypt::FNA; 1';
|
|
2
|
|
|
|
|
24931
|
|
|
2
|
|
|
|
|
56
|
|
24
|
2
|
|
|
2
|
|
7236
|
our $can_use_threads = eval 'use threads qw(yield); 1';
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# fine caricamento lib
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $VERSION = '0.10';
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# metodi ed attributi
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new {
|
32
|
0
|
|
|
0
|
1
|
|
my $class = shift;
|
33
|
0
|
|
|
|
|
|
my $init = shift;
|
34
|
0
|
|
|
|
|
|
my $self={};
|
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
bless $self,$class;
|
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$self->r($init->{r});
|
39
|
0
|
|
|
|
|
|
$self->angle($init->{angle});
|
40
|
0
|
|
|
|
|
|
$self->square($init->{square});
|
41
|
0
|
|
|
|
|
|
$self->magic($init->{magic});
|
42
|
0
|
|
|
|
|
|
$self->message($init->{message});
|
43
|
0
|
|
|
|
|
|
$self->salted($init->{salted});
|
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return $self
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub r {
|
49
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
50
|
0
|
0
|
|
|
|
|
if (@_) {
|
51
|
0
|
|
|
|
|
|
$self->{r}=shift
|
52
|
|
|
|
|
|
|
}
|
53
|
0
|
|
|
|
|
|
return $self->{r}
|
54
|
|
|
|
|
|
|
}
|
55
|
|
|
|
|
|
|
sub angle {
|
56
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
57
|
0
|
0
|
|
|
|
|
if (@_) {
|
58
|
0
|
|
|
|
|
|
$self->{angle}=shift
|
59
|
|
|
|
|
|
|
}
|
60
|
0
|
|
|
|
|
|
return $self->{angle}
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
sub square {
|
63
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
64
|
0
|
0
|
|
|
|
|
if (@_) {
|
65
|
0
|
|
|
|
|
|
$self->{square}=shift
|
66
|
|
|
|
|
|
|
}
|
67
|
0
|
|
|
|
|
|
return $self->{square}
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
sub magic {
|
70
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
71
|
0
|
0
|
|
|
|
|
if (@_) {
|
72
|
0
|
|
|
|
|
|
$self->{magic}=shift
|
73
|
|
|
|
|
|
|
}
|
74
|
0
|
|
|
|
|
|
return $self->{magic}
|
75
|
|
|
|
|
|
|
}
|
76
|
|
|
|
|
|
|
sub message {
|
77
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
78
|
0
|
0
|
|
|
|
|
if (@_) {
|
79
|
0
|
|
|
|
|
|
$self->{message}=shift
|
80
|
|
|
|
|
|
|
}
|
81
|
0
|
|
|
|
|
|
return $self->{message}
|
82
|
|
|
|
|
|
|
}
|
83
|
|
|
|
|
|
|
sub salted {
|
84
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
85
|
0
|
0
|
|
|
|
|
if (@_) {
|
86
|
0
|
|
|
|
|
|
$self->{salted}=shift
|
87
|
|
|
|
|
|
|
}
|
88
|
0
|
|
|
|
|
|
return $self->{salted}
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub encrypt_files {
|
92
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
93
|
0
|
|
|
|
|
|
my @files_to_encrypt=@_;
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
#istanza oggetto FNA
|
96
|
0
|
|
|
|
|
|
my $krypto;
|
97
|
0
|
0
|
|
|
|
|
if ($can_use_FNA) {
|
98
|
0
|
|
|
|
|
|
$krypto=$self->make_fna_object
|
99
|
|
|
|
|
|
|
} else {
|
100
|
0
|
|
|
|
|
|
push(@{$self->{message}},22);
|
|
0
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
return
|
102
|
0
|
|
|
|
|
|
}
|
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my @thr;
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# TRY
|
107
|
0
|
0
|
|
|
|
|
if ($can_use_threads) {
|
108
|
0
|
|
|
|
|
|
for (@files_to_encrypt) {
|
109
|
|
|
|
|
|
|
push @thr,threads->new(sub
|
110
|
|
|
|
|
|
|
{
|
111
|
0
|
|
|
0
|
|
|
my $krypto=shift;
|
112
|
0
|
|
|
|
|
|
my $file_to_encrypt=shift;
|
113
|
0
|
|
|
|
|
|
my $file_encrypted=$file_to_encrypt.".fna";
|
114
|
0
|
|
|
|
|
|
$krypto->encrypt_file($file_to_encrypt,$file_encrypted);
|
115
|
0
|
|
|
|
|
|
threads->yield()
|
116
|
|
|
|
|
|
|
},
|
117
|
0
|
|
|
|
|
|
$krypto,
|
118
|
|
|
|
|
|
|
$_
|
119
|
|
|
|
|
|
|
);
|
120
|
|
|
|
|
|
|
}
|
121
|
0
|
|
|
|
|
|
for (@thr) {
|
122
|
0
|
|
|
|
|
|
$_->join()
|
123
|
|
|
|
|
|
|
}
|
124
|
|
|
|
|
|
|
# CATCH
|
125
|
|
|
|
|
|
|
} else {
|
126
|
0
|
|
|
|
|
|
for (@files_to_encrypt) {
|
127
|
0
|
|
|
|
|
|
$krypto->encrypt_file($_,$_.'.fna')
|
128
|
|
|
|
|
|
|
}
|
129
|
|
|
|
|
|
|
}
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
}
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub decrypt_files {
|
134
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
135
|
0
|
|
|
|
|
|
my @files_to_decrypt=@_;
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#istanza oggetto FNA
|
138
|
0
|
|
|
|
|
|
my $krypto;
|
139
|
0
|
0
|
|
|
|
|
if ($can_use_FNA) {
|
140
|
0
|
|
|
|
|
|
$krypto=$self->make_fna_object
|
141
|
|
|
|
|
|
|
} else {
|
142
|
|
|
|
|
|
|
# aggiungere codice errore 22 che informa che fna non è installato
|
143
|
0
|
|
|
|
|
|
push(@{$self->{message}},22);
|
|
0
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
return
|
145
|
0
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my @thr;
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# TRY
|
150
|
0
|
0
|
|
|
|
|
if ($can_use_threads) {
|
151
|
0
|
|
|
|
|
|
for (@files_to_decrypt) {
|
152
|
|
|
|
|
|
|
push @thr,threads->new(sub
|
153
|
|
|
|
|
|
|
{
|
154
|
0
|
|
|
0
|
|
|
my $krypto=shift;
|
155
|
0
|
|
|
|
|
|
my $file_to_decrypt=shift;
|
156
|
0
|
|
|
|
|
|
my $file_decrypted=$file_to_decrypt;
|
157
|
0
|
|
|
|
|
|
$file_decrypted=~ s/\.fna$//;
|
158
|
0
|
|
|
|
|
|
$krypto->decrypt_file($file_to_decrypt,$file_decrypted);
|
159
|
0
|
|
|
|
|
|
threads->yield()
|
160
|
|
|
|
|
|
|
},
|
161
|
0
|
|
|
|
|
|
$krypto,
|
162
|
|
|
|
|
|
|
$_
|
163
|
|
|
|
|
|
|
);
|
164
|
|
|
|
|
|
|
}
|
165
|
0
|
|
|
|
|
|
for (@thr) {
|
166
|
0
|
|
|
|
|
|
$_->join()
|
167
|
|
|
|
|
|
|
}
|
168
|
|
|
|
|
|
|
# CATCH
|
169
|
|
|
|
|
|
|
} else {
|
170
|
0
|
|
|
|
|
|
for (@files_to_decrypt) {
|
171
|
0
|
|
|
|
|
|
my $file_to_decrypt=$_;
|
172
|
0
|
|
|
|
|
|
my $file_decrypted=$file_to_decrypt;
|
173
|
0
|
|
|
|
|
|
$file_decrypted=~ s/\.fna$//;
|
174
|
0
|
|
|
|
|
|
$krypto->decrypt_file($file_to_decrypt,$file_decrypted)
|
175
|
|
|
|
|
|
|
}
|
176
|
|
|
|
|
|
|
}
|
177
|
|
|
|
|
|
|
}
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub make_fna_object {
|
180
|
0
|
|
|
0
|
1
|
|
my $self=shift;
|
181
|
0
|
|
|
|
|
|
my $krypto=Crypt::FNA->new(
|
182
|
|
|
|
|
|
|
{
|
183
|
|
|
|
|
|
|
r=> $self->r,
|
184
|
|
|
|
|
|
|
angle => $self->angle,
|
185
|
|
|
|
|
|
|
square => $self->square,
|
186
|
|
|
|
|
|
|
magic => $self->magic,
|
187
|
|
|
|
|
|
|
salted => $self->salted
|
188
|
|
|
|
|
|
|
}
|
189
|
|
|
|
|
|
|
);
|
190
|
0
|
|
|
|
|
|
return $krypto
|
191
|
|
|
|
|
|
|
}
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# end metodi ed attributi
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
1;
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# POD SECTION
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 NAME
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Crypt::FNA::Async
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 VERSION
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Version 0.10
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Crypt::FNA::Async allow you to parallel encrypt/decrypt on a multicore CPU (and/or hyperthreading CPU).
|
210
|
|
|
|
|
|
|
If threads are not supported, the computation will take place in a synchronous rather than asynchronous.
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 CONSTRUCTOR METHOD
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
use Crypt::FNA::Async;
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
my $krypto_async=Crypt::FNA::Async->new(
|
218
|
|
|
|
|
|
|
{
|
219
|
|
|
|
|
|
|
r=> '8',
|
220
|
|
|
|
|
|
|
angle => [56,-187,215,64],
|
221
|
|
|
|
|
|
|
square => 4096,
|
222
|
|
|
|
|
|
|
magic => 2,
|
223
|
|
|
|
|
|
|
salted => 'true'
|
224
|
|
|
|
|
|
|
}
|
225
|
|
|
|
|
|
|
);
|
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my $krypto_async=Crypt::FNA::Async->new();
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head2 ATTRIBUTE r
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
see attribute 'r' of Crypt::FNA
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head2 ATTRIBUTE angle
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
see attribute 'angle' of Crypt::FNA
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head2 ATTRIBUTE square
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
see attribute 'square' of Crypt::FNA
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 ATTRIBUTE magic
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
see attribute 'magic' of Crypt::FNA
|
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head2 ATTRIBUTE salted
|
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
see attribute 'salted' of Crypt::FNA
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 ATTRIBUTE message
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
see attribute 'message' of Crypt::FNA
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 METHODS
|
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head2 new
|
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
See CONSTRUCTOR METHOD
|
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head2 encrypt_files
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
This method encrypt the input plain files to output crypted files.
|
266
|
|
|
|
|
|
|
The syntax is:
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
$krypto_async->encrypt_files($name_plain_file1, $name_plain_file2,...)
|
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 decrypt_files
|
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This method decrypt the input crypted files in the output plain file.
|
275
|
|
|
|
|
|
|
The syntax is:
|
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
$krypto_async->decrypt_files($name_encrypted_file1, $name_encrypted_file2,...)
|
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head2 make_fna_object
|
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Internal use, make a fna object
|
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 AUTHOR
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Mario Rossano
|
287
|
|
|
|
|
|
|
software@netlogicalab.com
|
288
|
|
|
|
|
|
|
software@netlogica.it
|
289
|
|
|
|
|
|
|
http://www.netlogicalab.com
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 BUGS
|
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
Please, send me your alerts to software@netlogica.it
|
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head1 SUPPORT
|
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Write me :) software@netlogica.it
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Crypt::FNA::Async by Mario Rossano, http://www.netlogicalab.com
|
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
This pod text by Mario Rossano
|
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
Copyright (C) 2009 Mario Rossano aka Anak
|
307
|
|
|
|
|
|
|
birthday 05/08/1970; birthplace: Italy
|
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
310
|
|
|
|
|
|
|
under the terms of either:
|
311
|
|
|
|
|
|
|
CC-NC-BY-SA
|
312
|
|
|
|
|
|
|
license http://creativecommons.org/licenses/by-nc-sa/2.5/it/deed.en
|
313
|
|
|
|
|
|
|
Creative Commons License: http://i.creativecommons.org/l/by-nc-sa/2.5/it/88x31.png
|
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
FNA Fractal Numerical Algorithm for a new cryptography technology, author Mario Rossano
|
316
|
|
|
|
|
|
|
is licensed under a: http://creativecommons.org/B/by-nc-sa/2.5/it/deed.en - Creative Commons Attribution-Noncommercial-Share Alike 2.5 Italy License
|
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
Permissions beyond the scope of this license may be available at software@netlogicalab.com |