File Coverage

bin/create_crypted_password
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             #! /usr/local/bin/perl -w
2 1     1   2318 use strict;
  1         2  
  1         70  
3 1     1   7 use autodie;
  1         2  
  1         5  
4              
5 1     1   5115 use Crypt::CBC;
  1         2  
  1         38  
6 1     1   773 use Getopt::Long;
  1         10733  
  1         4  
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, '>', $options{'file-name'};
37             print $fh $cipher->encrypt($options{password});
38             close($fh);