line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! /usr/local/bin/perl -w |
2
|
1
|
|
|
1
|
|
1408
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
3
|
use autodie; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4129
|
use Crypt::CBC; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
6
|
1
|
|
|
1
|
|
644
|
use Getopt::Long; |
|
1
|
|
|
|
|
8726
|
|
|
1
|
|
|
|
|
3
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my %options = (cipher => 'Rijndael', 'cipher-key' => 'BlahBlahBlahBlah'); |
9
|
|
|
|
|
|
|
GetOptions( |
10
|
|
|
|
|
|
|
\%options => qw( |
11
|
|
|
|
|
|
|
cipher-key|cipher_key|k=s |
12
|
|
|
|
|
|
|
password|p=s |
13
|
|
|
|
|
|
|
file-name|file_name|f=s |
14
|
|
|
|
|
|
|
) |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
if (! $options{password}) { |
18
|
|
|
|
|
|
|
# We'll try to read the password from a echoless STDIN |
19
|
|
|
|
|
|
|
eval "use Term::ReadKey"; |
20
|
|
|
|
|
|
|
if ($@) { |
21
|
|
|
|
|
|
|
die "Cannot load 'Term::ReadKey', no way to read password safely!\n"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
ReadMode('noecho'); |
24
|
|
|
|
|
|
|
print "Geef het password: "; |
25
|
|
|
|
|
|
|
chomp($options{password} = ReadLine(0)); |
26
|
|
|
|
|
|
|
ReadMode('restore'); |
27
|
|
|
|
|
|
|
print "\n"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $cipher = Crypt::CBC->new( |
31
|
|
|
|
|
|
|
-cipher => $options{cipher}, |
32
|
|
|
|
|
|
|
-key => $options{'cipher-key'}, |
33
|
|
|
|
|
|
|
-pbkdf => 'pbkdf2', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
open my $fh, '>:raw', $options{'file-name'}; |
37
|
|
|
|
|
|
|
print $fh $cipher->encrypt($options{password}); |
38
|
|
|
|
|
|
|
close($fh); |