From 2a03eac098be689fa11c371b926d3f2d8ae4c96d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 4 Jul 2011 10:00:53 +0200 Subject: Raps2.pm: Add pw_load_info method (pw_load for unencrypted data) --- lib/App/Raps2.pm | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index 720e942..96f37d7 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -177,6 +177,20 @@ sub pw_load { }; } +sub pw_load_info { + my ( $self, %data ) = @_; + + $data{file} //= $self->{xdg_data} . "/$data{name}"; + + my $key = $self->file_to_hash( $data{file} ); + + return { + url => $key->{url}, + login => $key->{login}, + salt => $key->{salt}, + }; +} + 1; __END__ @@ -203,7 +217,7 @@ This manual documents App::Raps2 version 0.4 =over -=item $raps2 = App::Raps2->new(I<%conf>) +=item $raps2 = App::Raps2->new( I<%conf> ) Returns a new B object. @@ -217,17 +231,12 @@ B of key setup, passed on to App::Raps2::Password(3pm). =back -=item $raps2->file_to_hash(I<$file>) - -Reads $file (lines with key/value separated by whitespace) and returns a -hashref with its key/value pairs. - -=item $raps2->get_master_password([I<$password>]) +=item $raps2->get_master_password( [I<$password>] ) 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>) +=item $raps2->pw_save( I<%data> ) Write an account as specified by I to the store. Requires B to have been called before. @@ -250,11 +259,21 @@ The following I keys are supported: =back -=item $raps2->pw_load(B => I | B => I) +=item $raps2->pw_load( B => I | B => I ) + +Load a password from I (or account I), requires +B to have been called before. + +Returns a hashref containing its url, login, salt and decrypted password and +extra. + +=item $raps2->pw_load_info( B => I | B => I ) -Loads a password from I (or account I), requires -B to have been called before. Returns a hashref -containing its url, login and decrypted password and extra. +Load all unencrypted data from I (or account I). Unlike +B, this method does not require a prior call to +B. + +Returns a hashref with url, login and salt. =back @@ -288,6 +307,11 @@ Returns the App::Raps2::Password(3pm) object. Returns the App::Raps2::UI(3pm) object. +=item $raps2->file_to_hash( I<$file> ) + +Reads $file (lines with key/value separated by whitespace) and returns a +hashref with its key/value pairs. + =back =head1 DIAGNOSTICS -- cgit v1.2.3