version 1.1, 2007/01/28 16:17:54 |
version 1.2, 2007/01/30 04:59:55 |
|
|
|
|
use YAML; |
use YAML; |
|
|
use lib 'lib'; |
use Palm::PDB; |
use Palm::Keyring; |
use Palm::Keyring; |
|
|
my $Default_File = $ENV{'HOME'} . '/.jpilot/Keys-Gtkr.pdb'; |
my $Default_File = $ENV{'HOME'} . '/.jpilot/Keys-Gtkr.pdb'; |
|
|
); |
); |
|
|
$PDBFile ||= $Default_File; |
$PDBFile ||= $Default_File; |
my $pdb = new Palm::Keyring(); |
my $pdb = new Palm::PDB(); |
$pdb->Load($PDBFile) || die "Couldn't load '$PDBFile': $!"; |
$pdb->Load($PDBFile) || die "Couldn't load '$PDBFile': $!"; |
|
|
if ($Action_List) { |
if ($Action_List) { |
|
|
exit; |
exit; |
|
|
|
|
#$pdb->Decrypt('12345'); |
|
#print Dump $pdb; |
|
|
|
#-------------------------------------------------- |
|
# my $new_record = $pdb->append_Record(); |
|
# |
|
# $new_record->{plaintext} = { |
|
# name => 'Test3', |
|
# account => 'anothertestaccount', |
|
# password => 'adifferentmypass', |
|
# description => 'now that really roxorZ!', |
|
# }; |
|
# |
|
#$pdb->Encrypt('12345'); |
|
# |
|
#$pdb->Write("Keys-GtkrNEW.PDB"); |
|
#-------------------------------------------------- |
|
|
|
|
|
sub show_list |
sub show_list |
{ |
{ |
print "Showing List\n"; |
print "Showing List\n"; |
foreach my $r (@{ $pdb->{'records'} }) { |
foreach (0..$#{ $pdb->{'records'} }) { |
next unless $r->{'plaintext'}; |
next if $_ == 0; |
|
my $r = $pdb->{'records'}->[$_]; |
my $category = |
my $category = |
$pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; |
$pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; |
|
|
|
|
$matched++ if uc($category) eq uc($cat); |
$matched++ if uc($category) eq uc($cat); |
} |
} |
foreach my $name (@{ $Names}) { |
foreach my $name (@{ $Names}) { |
$matched++ if uc($r->{'plaintext'}->{'name'}) eq uc($name); |
$matched++ if uc($r->{'data'}) eq uc($name); |
} |
} |
next if ( @{ $Categories } || @{ $Names } ) && not $matched; |
next if ( @{ $Categories } || @{ $Names } ) && not $matched; |
|
|
# XXX Fix up formatting |
# XXX Fix up formatting |
print $r->{'plaintext'}->{'name'} . |
print $r->{'data'} . |
":" . |
":" . |
$r->{'category'} . |
$r->{'category'} . |
":" . |
":" . |
|
|
|
|
sub show_items |
sub show_items |
{ |
{ |
decrypt() || die "Couldn't decrypt file!"; |
get_password() || die "Couldn't decrypt file!"; |
|
|
foreach my $r (@{ $pdb->{'records'} }) { |
foreach (0..$#{ $pdb->{'records'} }) { |
next unless $r->{'plaintext'}; |
next if $_ == 0; |
|
my $r = $pdb->{'records'}->[$_]; |
|
|
my $category = |
my $category = |
$pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; |
$pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; |
|
|
|
|
$matched++ if uc($category) eq uc($cat); |
$matched++ if uc($category) eq uc($cat); |
} |
} |
foreach my $name (@{ $Names}) { |
foreach my $name (@{ $Names}) { |
$matched++ if uc($r->{'plaintext'}->{'name'}) eq uc($name); |
$matched++ if uc($r->{'data'}) eq uc($name); |
} |
} |
next if ( @{ $Categories } || @{ $Names } ) && not $matched; |
next if ( @{ $Categories } || @{ $Names } ) && not $matched; |
|
|
|
my $a = $pdb->Decrypt($r); |
|
|
# XXX Fix up formatting |
# XXX Fix up formatting |
print $r->{'plaintext'}->{'name'} . |
print $r->{'data'} . "\n\t" . |
"\n\t" . |
"Category: " . $category . "\n\t" . |
"Category: " . $category . |
"Account: " . $a->{'account'} . "\n\t" . |
"\n\t" . |
"Password: " . $a->{'password'} . "\n"; |
"Account: " . $r->{'plaintext'}->{'account'} . |
print "\tNotes: " . $a->{'notes'} . "\n" if $a->{'notes'}; |
"\n\t" . |
|
"Password: " . $r->{'plaintext'}->{'password'} . |
|
"\n"; |
|
print "\tDescription: " . $r->{'plaintext'}->{'description'} . "\n" |
|
if $r->{'plaintext'}->{'description'}; |
|
|
|
} |
} |
|
|
} |
} |
|
|
die "not implemented!"; |
die "not implemented!"; |
} |
} |
|
|
sub decrypt |
sub get_password |
{ |
{ |
while (1) { |
while (1) { |
print "Enter Password: "; |
print "Enter Password: "; |
|
|
$read =~ s/\s*$//; |
$read =~ s/\s*$//; |
|
|
#return 1 if |
#return 1 if |
$pdb->Decrypt($read) && return 1; |
$pdb->Password($read) && return 1; |
#print Dump $read, $pdb; |
#print Dump $read, $pdb; |
#exit; |
#exit; |
} |
} |