1Crypt::PWSafe3(3)     User Contributed Perl Documentation    Crypt::PWSafe3(3)
2
3
4

NAME

6       Crypt::PWSafe3 - Read and write Passwordsafe v3 files
7

SYNOPSIS

9        use Crypt::PWSafe3;
10        my $vault = Crypt::PWSafe3->new(file => 'filename.psafe3', password => 'somesecret');
11
12        # fetch all database records
13        my @records = $vault->getrecords();
14        foreach my $record (@records) {
15          print $record->uuid;
16          print $record->title;
17          print $record->passwd;
18          # see Crypt::PWSafe3::Record for more details on accessing records
19        }
20
21        # same as above but don't detach records from vault
22        foreach my $uuid ($vault->looprecord) {
23          # either change a record
24          $vault->modifyrecord($uuid, passwd => 'p1');
25
26          # or just access it directly
27          print $vault->{record}->{$uuid}->title;
28        }
29
30        # add a new record
31        $vault->newrecord(user => 'u1', passwd => 'p1', title => 't1');
32
33        # modify an existing record
34        $vault->modifyrecord($uuid, passwd => 'p1');
35
36        # replace a record (aka edit it)
37        my $record = $vault->getrecord($uuid);
38        $record->title('t2');
39        $record->passwd('foobar');
40        $vault->addrecord($record);
41
42        # mark the vault as modified (not required if
43        # changes were done with ::modifyrecord()
44        $vault->markmodified();
45
46        # save the vault
47        $vault->save();
48
49        # save it under another name using another password
50        $vault->save(file => 'another.pwsafe3', passwd => 'blah');
51
52        # access database headers
53        print $vault->getheader('wholastsaved')->value();
54        print scalar localtime($vault->getheader('lastsavetime')->value());
55
56        # add/replace a database header
57        my $h = Crypt::PWSafe3::HeaderField->new(name => 'savedonhost', value => 'localhost');
58        $vault->addheader($h);
59

DESCRIPTION

61       Crypt::PWSafe3 provides read and write access to password database
62       files created by Password Safe V3 (and up) available at
63       http://passwordsafe.sf.net.
64

METHODS

66   new()
67       The new() method creates a new Crypt::PWSafe3 object. Any parameters
68       must be given as hash parameters.
69
70        my $vault = Crypt::PWSafe3->new(
71                            file     => 'vault.psafe3',
72                            password => 'secret',
73                            whoami   => 'user1',
74                            program  => 'mypwtool v1',
75                            create   => 0,   # or 1
76        );
77
78       Mandatory parameters:
79
80       file
81           Specifies the password safe (v3) file. If it exists it will be read
82           in. Otherwise it will be created if you call save().
83
84       password
85           The password required to decrypt the password safe file.
86
87       Optional parameters:
88
89       whoami
90           Specifies the user who saves the password safe file.  If omitted
91           the environment variable USER will be used when calling save().
92
93       program
94           Specifies which program saved the password safe file.  If omitted,
95           the content of the perl variable $0 will be used, which contains
96           the name of the current running script.
97
98       create
99           If set to 0, new() will fail if the file doesn't exist, otherwise
100           it will try to create it. Enabled by default.
101
102       The optional parameters will become header fields of the password safe
103       file. You can manually set/override more headers. See section
104       addheader() for more details.
105
106   getrecords()
107       Returns a list of all records found in the password safe file. Each
108       element is an Crypt::PWSafe3::Record object.
109
110       A record object is identified by its UUID4 value, which is a unique
111       identifier. You can access the uuid by:
112
113        $record->uuid
114
115       Accessing other record properties works the same. For more details,
116       refer to Crypt::PWSafe3::Record.
117
118       Note: record objects returned by getrecords() are still associated with
119       the Crypt::PWSafe3 object. So, if you modify a field of such a record,
120       the change will be populated back into the vault. Of course you'd still
121       need to save it.
122
123       Sample:
124
125        foreach my $rec ($vault->getrecords) {
126          $rec->note('blah fasel');
127        }
128        $vault->save();
129
130       However, it's also possible to use the modifyrecord() method, see
131       below.
132
133   looprecord()
134       Returns a list of UUIDs of all known records. You can use this list to
135       iterate over the records without copying them and optionally changing
136       them in place.
137
138       Example:
139
140        foreach my $uuid ($vault->looprecord) {
141          # either change a record
142          $vault->modifyrecord($uuid, passwd => 'p1');
143
144          # or just access it directly
145          print $vault->{record}->{$uuid}->title;
146        }
147
148   modifyrecord(uuid, parameter-hash)
149       Modifies the record identified by the given UUID using the values of
150       the supplied parameter hash.
151
152       Example:
153
154          $vault->modifyrecord($uuid, passwd => 'p1');
155
156       The parameter hash may contain any valid record field type with
157       according values. Refer to Crypt::PWSafe3::Record for details about
158       available fields.
159
160   newrecord(parameter-hash)
161       Create a new record. The UUID of the record will be generated
162       automatically. Refer to Crypt::PWSafe3::Record for details about
163       available fields.
164
165   addrecord(Crypt::PWSafe3::Record object)
166       Add a record to the vault. The record must be an Crypt::PWSafe3::Record
167       object.
168
169   deleterecord(uuid)
170       Delete the record identified by the given UUID.
171
172   save([parameter-hash])
173       Save the current password safe vault back to disk.
174
175       If not otherwise specified, use the same file and password as we used
176       to open it initially. If the file doesn't exist it will be created.
177
178       You may specify another filename and password here by using a parameter
179       hash.
180
181       Example:
182
183        $vault->save(file => 'anotherfile.psafe3', passwd => 'foo');
184
185       Please note, that the vault will be written to a temporary file first,
186       then this temporary file will be read in and if that works, it will be
187       moved over the destination file. This way the original file persists if
188       the written database gets corrupted by some unknown reason (a bug for
189       instance).
190
191   getheader(name)
192       Returns a raw Crypt::PWSafe3::HeaderField object.  Refer to
193       Crypt::PWSafe3::HeaderField for details how to access it.
194
195   addheader(object)
196       Adds a header field to the password safe database. The object parameter
197       must be an Crypt::PWSafe3::HeaderField object.
198
199       If the header already exists it will be replaced.
200
201       Refer to Crypt::PWSafe3::HeaderField for details how to create new ones
202       .
203

AUTHOR

205       T.v.Dein <tlinden@cpan.org>
206

BUGS

208       Report bugs to
209       http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-PWSafe3.
210

SEE ALSO

212       Subclasses:
213
214       Crypt::PWSafe3::Record Crypt::PWSafe3::Field
215       Crypt::PWSafe3::HeaderField
216
217       Password Safe Homepage: <http://passwordsafe.sourceforge.net/>
218
219       Another (read-only) perl module: Crypt::Pwsafe
220
221       A python port of Password Safe:
222       <http://www.christoph-sommer.de/loxodo/> Many thanks to Christoph
223       Sommer, his python library inspired me a lot and in fact most of the
224       concepts in this module are his ideas ported to perl.
225
227       Copyright (c) 2011-2016 by T.v.Dein <tlinden@cpan.org>.
228

LICENSE

230       This program is free software; you can redistribute it and/or modify it
231       under the same terms of the Artistic License 2.0, see:
232       <http://www.perlfoundation.org/artistic_license_2_0>
233

VERSION

235       Crypt::PWSafe3 Version 1.22.
236
237
238
239perl v5.32.1                      2021-01-27                 Crypt::PWSafe3(3)
Impressum