From 1bc1cec23206cf212573fd283d81f8e030155261 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 4 Jul 2011 09:49:24 +0200 Subject: Raps2.pm: get_master_password: Accept password as optional argument This way, it is possible to use App::Raps2 in non-CLI applications. --- Changelog | 1 + lib/App/Raps2.pm | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index 3306369..8096a3c 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ git HEAD * Rename pw_get to pw_load * pw_load now also returns the salt * file_to_hash now returns a hashref instead of a hash + * Allow password to be passed as argument to get_master_password App::Raps2 0.4 - Sun Jul 03 2011 diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index faf74d9..720e942 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -63,8 +63,11 @@ sub sanity_check { } sub get_master_password { - my ($self) = @_; - my $pass = $self->ui->read_pw( 'Master Password', 0 ); + my ( $self, $pass ) = @_; + + if ( not defined $pass ) { + $pass = $self->ui->read_pw( 'Master Password', 0 ); + } $self->{pass} = App::Raps2::Password->new( cost => $self->{default}->{cost}, @@ -219,16 +222,17 @@ B of key setup, passed on to App::Raps2::Password(3pm). Reads $file (lines with key/value separated by whitespace) and returns a hashref with its key/value pairs. -=item $raps2->get_master_password() +=item $raps2->get_master_password([I<$password>]) -Asks the user for the master passphrase. +Sets the master password used to encrypt all accounts. Uses I if +specified, otherwise it asks the user via App::Raps2::UI(3pm). =item $raps2->pw_save(I<%data>) Write an account as specified by I to the store. Requires B to have been called before. -The following I keys are possible: +The following I keys are supported: =over -- cgit v1.2.3