Merge branch 'master' of github.com:Difrex/PM
This commit is contained in:
commit
28e0231ab3
36
GPG.pm
36
GPG.pm
@ -10,7 +10,10 @@ sub new {
|
|||||||
my $home = $ENV{HOME};
|
my $home = $ENV{HOME};
|
||||||
my $db = $home . "/.PM/db.sqlite";
|
my $db = $home . "/.PM/db.sqlite";
|
||||||
|
|
||||||
my $self = { _db => $db, };
|
my $self = {
|
||||||
|
_db => $db,
|
||||||
|
_home => $home,
|
||||||
|
};
|
||||||
|
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
return $self;
|
return $self;
|
||||||
@ -26,13 +29,30 @@ sub encrypt_db {
|
|||||||
@rm_db = ( "rm", "-f", "$db" );
|
@rm_db = ( "rm", "-f", "$db" );
|
||||||
system(@rm_db) == 0 or die "Cannot remove old database: $!\n";
|
system(@rm_db) == 0 or die "Cannot remove old database: $!\n";
|
||||||
|
|
||||||
# gpg --output test.gpg --encrypt test -a --default-recipient-self
|
# Keys selection.
|
||||||
@enc_cmd = (
|
my @enc_cmd;
|
||||||
"gpg", "--output", "$db",
|
my $recipient;
|
||||||
"-a", "--default-recipient-self",
|
if ( -e $self->{_home} . "/.PM/.key" ) {
|
||||||
"--encrypt", "$file",
|
open my $key_f, "<" , $self->{_home} . "/.PM/.key"
|
||||||
);
|
or die "Cannot open file: $!\n";
|
||||||
|
while ( <$key_f> ) {
|
||||||
|
$recipient = $_;
|
||||||
|
}
|
||||||
|
@enc_cmd = (
|
||||||
|
"gpg", "--output", "$db",
|
||||||
|
"-a", "--recipient", "$recipient",
|
||||||
|
"--encrypt", "$file",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# gpg --output test.gpg --encrypt test -a --default-recipient-self
|
||||||
|
@enc_cmd = (
|
||||||
|
"gpg", "--output", "$db",
|
||||||
|
"-a", "--default-recipient-self",
|
||||||
|
"--encrypt", "$file",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
system(@enc_cmd) == 0
|
system(@enc_cmd) == 0
|
||||||
or die "Cannot encrypt!\nDecrypted file: $file\nTraceback: $!\n";
|
or die "Cannot encrypt!\nDecrypted file: $file\nTraceback: $!\n";
|
||||||
|
|
||||||
|
11
README.md
11
README.md
@ -32,9 +32,16 @@ Set this key(or another of cource) for default:
|
|||||||
|
|
||||||
vim ~/.gnupg/gpg.conf
|
vim ~/.gnupg/gpg.conf
|
||||||
# find string and uncomment or add it
|
# find string and uncomment or add it
|
||||||
default-key your@mail-address-key.org
|
default-key key_email@example.com
|
||||||
:wq
|
:wq
|
||||||
|
|
||||||
|
You can use not default key:
|
||||||
|
|
||||||
|
# Create file with key email
|
||||||
|
cat > ~/.PM/.key << EOF
|
||||||
|
key_email@example.com
|
||||||
|
EOF
|
||||||
|
|
||||||
First run:
|
First run:
|
||||||
|
|
||||||
$ ./pm.pl
|
$ ./pm.pl
|
||||||
@ -62,6 +69,6 @@ Show help screen:
|
|||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
* Import/Export with simple(only password) encryption
|
||||||
* Password lenght
|
* Password lenght
|
||||||
* Store decrypted DB into RAM not in /tmp/
|
* Store decrypted DB into RAM not in /tmp/
|
||||||
* Different keys selection
|
|
||||||
|
12
pm.pl
12
pm.pl
@ -80,9 +80,15 @@ if ( defined($opt_s) and defined($opt_n) and !defined($opt_o) ) {
|
|||||||
my $get_pass = $get_h->{password};
|
my $get_pass = $get_h->{password};
|
||||||
|
|
||||||
$copy->copy($get_pass);
|
$copy->copy($get_pass);
|
||||||
|
# TEST
|
||||||
print "Password copied to xclipboard.\nURI is "
|
use Term::ANSIColor;
|
||||||
. $get_h->{resource} . "\n";
|
print color 'green';
|
||||||
|
print "Password copied to xclipboard.";
|
||||||
|
print color 'reset';
|
||||||
|
print "\nURI is ";
|
||||||
|
print color 'bold blue';
|
||||||
|
print $get_h->{resource} . "\n";
|
||||||
|
print color 'reset';
|
||||||
}
|
}
|
||||||
elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) {
|
elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user