Start working on GPG module
This commit is contained in:
parent
2423a6d942
commit
dcb70474e3
14
Database.pm
14
Database.pm
@ -9,8 +9,11 @@ sub new {
|
||||
# Get home dir
|
||||
my $home = $ENV->{HOME};
|
||||
|
||||
my $gpg = GPG->new();
|
||||
|
||||
my $self = {
|
||||
_home => $home,
|
||||
_gpg => $gpg,
|
||||
};
|
||||
|
||||
bless $self, $class;
|
||||
@ -39,18 +42,21 @@ sub create_base {
|
||||
|
||||
# Check dir
|
||||
if ( !( -d $pm_dir ) ) {
|
||||
|
||||
# Create dirrectory
|
||||
@mkdir_cmd = ("mkdir", "$pm_dir");
|
||||
my @mkdir_cmd = ( "mkdir", "$pm_dir" );
|
||||
system(@mkdir_cmd) == 0 or die "Cannot create dir $pm_dir: $!\n";
|
||||
|
||||
# Create DB file
|
||||
@createdb_cmd = ("touch", "$pm_dir/db.sqlite");
|
||||
my @createdb_cmd = ( "touch", "$pm_dir/db.sqlite" );
|
||||
system(@createdb_cmd) == 0 or die "Cannot create database file: $!\n";
|
||||
|
||||
# Create table. TODO: write this
|
||||
my $dbh = DBI->connect("dbi:SQLite:dbname=$pm_dir/db.sqlite","","");
|
||||
my $dbh
|
||||
= DBI->connect( "dbi:SQLite:dbname=$pm_dir/db.sqlite", "", "" );
|
||||
print "Create database schema\n";
|
||||
my $q_table = "create table passwords(name VARCHAR(32), resource TEXT, password TEXT)";
|
||||
my $q_table
|
||||
= "create table passwords(name VARCHAR(32), resource TEXT, password TEXT)";
|
||||
$dbh->do($q_table);
|
||||
|
||||
# Encrypt db
|
||||
|
10
pm.pl
10
pm.pl
@ -44,11 +44,12 @@ EOF
|
||||
sub init() {
|
||||
my $opt_string = 'swn:l:p:rhv';
|
||||
getopts("$opt_string") or usage();
|
||||
our ($opt_s, $opt_w, $opt_n, $opt_r,
|
||||
$opt_l, $opt_p, $opt_h, $opt_v);
|
||||
our ( $opt_s, $opt_w, $opt_n, $opt_r, $opt_l, $opt_p, $opt_h, $opt_v );
|
||||
|
||||
print "Simple password manager writed in Perl.\nVersion: ".
|
||||
$VERSION."\n" and exit 0 if $opt_v;
|
||||
print "Simple password manager writed in Perl.\nVersion: "
|
||||
. $VERSION
|
||||
. "\n" and exit 0
|
||||
if $opt_v;
|
||||
usage if $opt_h;
|
||||
}
|
||||
|
||||
@ -56,5 +57,6 @@ sub init() {
|
||||
init();
|
||||
|
||||
my $pass = Password->new();
|
||||
|
||||
# Don't use it's before GPG and Database
|
||||
# $pass->check_config() == 0 or die "$!\n";
|
Loading…
Reference in New Issue
Block a user