Author image Daniel Friesel
and 1 contributors


App::Raps2 - A Password safe


    use App::Raps2;

    my $raps2 = App::Raps2->new();


App::Raps2 is the backend for raps2, a simple commandline password safe.


This manual documents App::Raps2 version 0.54


$raps2 = App::Raps2->new( %conf )

Returns a new App::Raps2 object.

Accepted configuration parameters are:

cost => int

cost of key setup, passed on to App::Raps2::Password(3pm).

Default: 12

no_cli => bool

If set to true, App::Raps2 assumes it will not be used as a CLI. It won't initialize its Term::ReadLine object and won't try to read anything from the terminal.

pwgen_cmd => comand

Command to use in generate_password.

Default: pwgen -s 23 1

Note that the cost and pwgen_cmd options specified here take precedence over those loaded from the config file.

$raps2->get_master_password( [$password] )

Sets the master password used to encrypt all accounts. Uses password if specified, otherwise it asks the user via App::Raps2::UI(3pm).

$raps2->pw_load( file => file | name => name )

Load a password from file (or account name), requires get_master_password to have been called before.

Returns a hashref containing its url, login, salt, cost and decrypted password and extra.

$raps2->pw_load_info( file => file | name => name )

Load all unencrypted data from file (or account name). Unlike pw_load, this method does not require a prior call to get_master_password.

Returns a hashref with url, login, salt and cost.

$raps2->pw_save( %data )

Write an account as specified by data to the store. Requires get_master_password to have been called before.

The following data keys are supported:

password => password to encrypt (mandatory)
salt => salt
cost => cost (optional, inferred from new / the config otherwise)
file => file | name => name (one must be set)
url => url (optional)
login => login (optional)
extra => extra (optiona)

Returns the App::Raps2::UI(3pm) object.


Returns the current config value of key, either set by new or loaded from the defaults config file.


Runs pwgen_cmd (as specified in new or the config file) and returns its first word of output, without trailing newlines / whitespaces.


You usually don't need to call these methods by yourself.


Creates a password file and asks the user to set a master password.


Load config. Automatically called by new.


Creates a defaults config file containing the default key setup cost and pwgen command.


Loads the defaults file. Automatically called by new.


Returns the App::Raps2::Password(3pm) object.

$raps2->file_to_hash( $file )

Reads $file (lines with key/value separated by whitespace) and returns a hashref with its key/value pairs.


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 new.

Calls create_config and create_defaults if no configs were found.


If anything goes wrong, App::Raps2 will die with a backtrace (using confess from Carp(3pm)).


App::Raps2::Password(3pm), App::Raps2::UI(3pm), File::BaseDir(3pm), File::Slurp(3pm).


Be aware that the password handling API is not yet stable. Also, so far the development concentrated on raps2, so this module / its documentation may not be completely up-to-date.


Copyright (C) 2011-2015 by Daniel Friesel <>