summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-06-11 22:59:58 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-06-11 22:59:58 +0200
commitc2520cdb9f42da700cf8241eb7c4b78308a9f176 (patch)
tree906cc0e74178abae10ec35853c92470a9e6ee225 /lib
parentf303e11a43325cecbd03a1a465903a3e2452e432 (diff)
Raps2.pm: pw_add / pw_get: Accept either filename or account name
Diffstat (limited to 'lib')
-rw-r--r--lib/App/Raps2.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/App/Raps2.pm b/lib/App/Raps2.pm
index 6b40cc2..cf5a404 100644
--- a/lib/App/Raps2.pm
+++ b/lib/App/Raps2.pm
@@ -133,6 +133,8 @@ sub ui {
sub pw_add {
my ( $self, %data ) = @_;
+ $data{file} //= $self->{xdg_data} . "/$data{name}";
+
my $pass_hash = $self->pw->encrypt( $data{password}, $data{salt} );
my $extra_hash = (
$data{extra}
@@ -184,6 +186,8 @@ sub cmd_add {
sub pw_get {
my ( $self, %data ) = @_;
+ $data{file} //= $self->{xdg_data} . "/$data{name}";
+
my %key = $self->file_to_hash( $data{file} );
return {
@@ -414,6 +418,19 @@ Returns the App::Raps2::Password(3pm) object.
Returns the App::Raps2::UI(3pm) object.
+=item $raps2->pw_add(I<%data>)
+
+Write an account as specified by I<data> to the store. Requires
+B<get_master_password> to have been called before. Requires I<data> keys are
+password, salt and either file or name, plus the optional url, login and
+extra.
+
+=item $raps2->pw_get(B<file> => I<file> | B<name> => I<name>)
+
+Loads a password from I<file> (or account I<name>), requires
+B<get_master_password> to have been called before. Returns a hashref
+containing its url, login and decrypted password and extra.
+
=item $raps2->cmd_add(I<$name>)
Adds a new password file called $name.