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 --- Changelog | 1 + bin/raps2 | 2 -- lib/App/Raps2.pm | 55 ++++++++++++++++++++++++++++--------------------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Changelog b/Changelog index 86f6b64..10fba16 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,7 @@ git HEAD * file_to_hash now returns a hashref instead of a hash * Allow password to be passed as argument to get_master_password * Add pw_load_info method + * The 'salt' argument to pw_add is now optional App::Raps2 0.4 - Sun Jul 03 2011 diff --git a/bin/raps2 b/bin/raps2 index cb74009..f908040 100755 --- a/bin/raps2 +++ b/bin/raps2 @@ -27,7 +27,6 @@ sub cmd_add { $raps2->get_master_password(); - my $salt = $raps2->pw->create_salt(); my $url = $raps2->ui->read_line('URL'); my $login = $raps2->ui->read_line('Login'); my $pass = $raps2->ui->read_pw( 'Password', 1 ); @@ -35,7 +34,6 @@ sub cmd_add { $raps2->pw_save( file => $pwfile, - salt => $salt, url => $url, login => $login, password => $pass, 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