diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-07-04 09:49:24 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-07-04 09:49:24 +0200 |
commit | 1bc1cec23206cf212573fd283d81f8e030155261 (patch) | |
tree | c06957030900eecf2450c201d212cb6fc818abb2 | |
parent | e496f621262e74133d9870cc197217552ad10185 (diff) |
Raps2.pm: get_master_password: Accept password as optional argument
This way, it is possible to use App::Raps2 in non-CLI applications.
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | lib/App/Raps2.pm | 14 |
2 files changed, 10 insertions, 5 deletions
@@ -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<cost> 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<password> 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<data> to the store. Requires B<get_master_password> to have been called before. -The following I<data> keys are possible: +The following I<data> keys are supported: =over |