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 $db = $home . "/.PM/db.sqlite";
|
||||
|
||||
my $self = { _db => $db, };
|
||||
my $self = {
|
||||
_db => $db,
|
||||
_home => $home,
|
||||
};
|
||||
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
@ -26,13 +29,30 @@ sub encrypt_db {
|
||||
@rm_db = ( "rm", "-f", "$db" );
|
||||
system(@rm_db) == 0 or die "Cannot remove old database: $!\n";
|
||||
|
||||
# gpg --output test.gpg --encrypt test -a --default-recipient-self
|
||||
@enc_cmd = (
|
||||
"gpg", "--output", "$db",
|
||||
"-a", "--default-recipient-self",
|
||||
"--encrypt", "$file",
|
||||
);
|
||||
|
||||
# Keys selection.
|
||||
my @enc_cmd;
|
||||
my $recipient;
|
||||
if ( -e $self->{_home} . "/.PM/.key" ) {
|
||||
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
|
||||
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
|
||||
# find string and uncomment or add it
|
||||
default-key your@mail-address-key.org
|
||||
default-key key_email@example.com
|
||||
:wq
|
||||
|
||||
You can use not default key:
|
||||
|
||||
# Create file with key email
|
||||
cat > ~/.PM/.key << EOF
|
||||
key_email@example.com
|
||||
EOF
|
||||
|
||||
First run:
|
||||
|
||||
$ ./pm.pl
|
||||
@ -62,6 +69,6 @@ Show help screen:
|
||||
|
||||
# TODO
|
||||
|
||||
* Import/Export with simple(only password) encryption
|
||||
* Password lenght
|
||||
* 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};
|
||||
|
||||
$copy->copy($get_pass);
|
||||
|
||||
print "Password copied to xclipboard.\nURI is "
|
||||
. $get_h->{resource} . "\n";
|
||||
# TEST
|
||||
use Term::ANSIColor;
|
||||
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) ) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user