diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-07-20 15:46:08 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-07-20 15:50:01 +0200 |
commit | 6d23a4563756e9129bd4741787954ffa6d7ee22e (patch) | |
tree | df4769f8d8d65f79a5567b91d2ac2ab2235d0bd4 /lib/App/Raps2.pm | |
parent | f778c553ef832660555822e9550864624bc8186b (diff) |
Raps2.pm: Add write_config method
Diffstat (limited to 'lib/App/Raps2.pm')
-rw-r--r-- | lib/App/Raps2.pm | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index d2520eb..5e72e1d 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -88,23 +88,37 @@ sub get_master_password { sub create_config { my ($self) = @_; - my $cost = $self->{default}{cost} // 12; + + $self->{default}{cost} //= 12; + $self->{master_cost} = $self->{default}{cost}; + my $pass = $self->{default}{master_password} // $self->ui->read_pw( 'Master Password', 1 ); $self->{pass} = App::Raps2::Password->new( - cost => $cost, + cost => $self->{master_cost}, passphrase => $pass, ); - my $hash = $self->pw->bcrypt(); - my $salt = $self->pw->salt(); + + $self->write_config(); + + return; +} + +sub write_config { + my ($self) = @_; + + my $cost = $self->{master_cost}; + my $salt = $self->pw->salt; + my $hash = $self->pw->bcrypt; + my $new_cost = $self->{default}{cost}; write_file( $self->{xdg_conf} . '/password', "cost ${cost}\n", "salt ${salt}\n", "hash ${hash}\n", - "new_cost ${cost}\n", + "new_cost ${new_cost}\n", ); return; |