From 6d23a4563756e9129bd4741787954ffa6d7ee22e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 20 Jul 2011 15:46:08 +0200 Subject: Raps2.pm: Add write_config method --- lib/App/Raps2.pm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'lib/App') 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; -- cgit v1.2.3