Crypt-Pwsafe
view release on metacpan or search on metacpan
lib/Crypt/Pwsafe.pm view on Meta::CPAN
die "Failed to open $file\n" unless defined $fh;
$pw = enter_combination() unless defined $pw;
my $header;
my $len = 72;
unless ($fh->read($header, $len) == $len) {
die "$file has < $len bytes.\n";
}
$header =~ /^PWS3/ or warn "$file is not a version 3 Password Safe data file.\n";
my $salt = substr($header, 4, 32);
my $n_iters = unpack('V', substr($header, 36, 4));
warn "$file uses < 2048 iterations of hash.\n" if $n_iters < 2048;
warn "$file uses $n_iters iterations of hash?\n" if $n_iters > 20480;
my $fhash = substr($header, 40, 32);
my $ptag = _stretch_key($salt, $n_iters, $fhash, $pw);
die "Bad safe combination.\n" unless $ptag;
my $crypt = "";
# Assume that the whole PWsafe file can comfortably fit into the memory
while ($fh->read(my $buf, 0x400000)) {
$crypt .= $buf;
}
$fh->close;
my $self = _decrypt($ptag, $crypt);
( run in 1.496 second using v1.01-cache-2.11-cpan-96521ef73a4 )