From 581559e3d6dcac68e7ae297f9b1247b63b143582 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 4 Jul 2011 12:22:22 +0200 Subject: Raps2.pm: pw_save: Make salt argument optional, restructure documentation while at it --- lib/App/Raps2.pm | 55 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'lib/App/Raps2.pm') diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm index 96f37d7..8971dd0 100644 --- a/lib/App/Raps2.pm +++ b/lib/App/Raps2.pm @@ -137,6 +137,7 @@ sub pw_save { my ( $self, %data ) = @_; $data{file} //= $self->{xdg_data} . "/$data{name}"; + $data{salt} //= $self->pw->create_salt(); my $pass_hash = $self->pw->encrypt( $data{password}, $data{salt} ); my $extra_hash = ( @@ -236,6 +237,22 @@ B of key setup, passed on to App::Raps2::Password(3pm). 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_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 ) + +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. + =item $raps2->pw_save( I<%data> ) Write an account as specified by I to the store. Requires @@ -247,7 +264,7 @@ The following I keys are supported: =item B => I (mandatory) -=item B => I (mandatory) +=item B => I =item B => I | B => I (one must be set) @@ -259,21 +276,9 @@ The following I keys are supported: =back -=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 ) - -Load all unencrypted data from I (or account I). Unlike -B, this method does not require a prior call to -B. +=item $raps2->ui() -Returns a hashref with url, login and salt. +Returns the App::Raps2::UI(3pm) object. =back @@ -283,14 +288,6 @@ You usually don't need to call these methods by yourself. =over -=item $raps2->sanity_check() - -Create working directories (~/.config/raps2 and ~/.local/share/raps2, or the -respective XDG environment variable contents), if they don't exist yet. -Automatically called by B. - -Calls B if no raps2 config was found. - =item $raps2->create_config() Creates a default config and asks the user to set a master password. @@ -303,15 +300,19 @@ Load config. Automatically called by B. Returns the App::Raps2::Password(3pm) object. -=item $raps2->ui() - -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. +=item $raps2->sanity_check() + +Create working directories (~/.config/raps2 and ~/.local/share/raps2, or the +respective XDG environment variable contents), if they don't exist yet. +Automatically called by B. + +Calls B if no raps2 config was found. + =back =head1 DIAGNOSTICS -- cgit v1.2.3