Crypt::PWSafe3(3)
Crypt::PWSafe3 π
okay bestie, so this is a Perl module β User Contributed Perl Documentation vibes β and it's literally the one that lets you read and write Password Safe v3 files. No cap. π
β¨ NAME β¨
Crypt::PWSafe3 β read and write Passwordsafe v3 files π
πΈ SYNOPSIS πΈ
here's the whole vibe, copy-paste ready:
use Crypt::PWSafe3;
my $vault = Crypt::PWSafe3->new(file => 'filename.psafe3', password => 'somesecret');
# fetch all database records
my @records = $vault->getrecords();
foreach my $record (@records) {
print $record->uuid;
print $record->title;
print $record->passwd;
# see Crypt::PWSafe3::Record for more details on accessing records
}
# same as above but don't detach records from vault
foreach my $uuid ($vault->looprecord) {
# either change a record
$vault->modifyrecord($uuid, passwd => 'p1');
# or just access it directly
print $vault->{record}->{$uuid}->title;
}
# add a new record
$vault->newrecord(user => 'u1', passwd => 'p1', title => 't1');
# modify an existing record
$vault->modifyrecord($uuid, passwd => 'p1');
# replace a record (aka edit it)
my $record = $vault->getrecord($uuid);
$record->title('t2');
$record->passwd('foobar');
$vault->addrecord($record);
# mark the vault as modified (not required if
# changes were done with ::modifyrecord()
$vault->markmodified();
# save the vault
$vault->save();
# save it under another name using another password
$vault->save(file => 'another.pwsafe3', passwd => 'blah');
# access database headers
print $vault->getheader('wholastsaved')->value();
print scalar localtime($vault->getheader('lastsavetime')->value());
# add/replace a database header
my $h = Crypt::PWSafe3::HeaderField->new(name => 'savedonhost', value => 'localhost');
$vault->addheader($h);
likeβ¦ look at that. it's giving competence. π₯
π¦ DESCRIPTION π¦
so Crypt::PWSafe3 hands you read and write access to password database files created by Password Safe V3 (and up, bestie, and up), which lives over at http://passwordsafe.sf.net. π«Ά
π METHODS π
π new()
new() builds you a brand new Crypt::PWSafe3 object. every param goes in as a hash parameter, no positional chaos here:
my $vault = Crypt::PWSafe3->new(
file => 'vault.psafe3',
password => 'secret',
whoami => 'user1',
program => 'mypwtool v1',
create => 0, # or 1
);
π Mandatory parameters:
fileβ points at the password safe (v3) file. if it already exists, it gets read in. if it doesn't, it gets created when you callsave(). πpasswordβ the password needed to decrypt the password safe file. the whole point, honestly. π
π Optional parameters:
whoamiβ says which user saved the password safe file. skip it and the environment variableUSERgets used when you callsave(). πprogramβ says which program saved the password safe file. skip it and the contents of the perl variable$0get used, which is the name of the currently running script. β¨createβ if it's set to0,new()fails when the file doesn't exist; otherwise it'll try to create it. Enabled by default. π±
heads up: those optional parameters become header fields of the password safe file. you can manually set/override more headers yourself β check the addheader() section for the tea. π
π getrecords()
returns a list of all records found in the password safe file. every element is a Crypt::PWSafe3::Record object. π
each record object is identified by its UUID4 value, which is a unique identifier. you grab the uuid like:
$record->uuid
accessing the other record properties works the exact same way. for more deets, go read Crypt::PWSafe3::Record. π
Note: record objects returned bygetrecords()are still associated with theCrypt::PWSafe3object. so if you modify a field of such a record, that change gets populated back into the vault. obviously you'd still need to save it. (yes, it's giving main character energy β the record stays linked.) π
Sample:
foreach my $rec ($vault->getrecords) {
$rec->note('blah fasel');
}
$vault->save();
but bestie, you can also just use the modifyrecord() method instead β see below. π«Ά
π§ looprecord()
returns a list of UUIDs of all known records. use this list to iterate over the records without copying them, and optionally change them right there in place. iconic behavior honestly. π
Example:
foreach my $uuid ($vault->looprecord) {
# either change a record
$vault->modifyrecord($uuid, passwd => 'p1');
# or just access it directly
print $vault->{record}->{$uuid}->title;
}
β modifyrecord(uuid, parameter-hash)
modifies the record identified by the given UUID, using the values from the parameter hash you supply. π―
Example:
$vault->modifyrecord($uuid, passwd => 'p1');
the parameter hash can hold any valid record field type with its matching value. refer to Crypt::PWSafe3::Record for details on which fields are available. πΈ
π newrecord(parameter-hash)
creates a new record. the UUID of the record gets generated automatically for you, so don't stress about it. refer to Crypt::PWSafe3::Record for details on which fields are available. β¨
π addrecord(Crypt::PWSafe3::Record object)
adds a record to the vault. the record must be a Crypt::PWSafe3::Record object. no shortcuts, no random hashes. π
π deleterecord(uuid)
deletes the record identified by the given UUID. poof. gone. π«‘
π save([parameter-hash])
saves the current password safe vault back to disk. πΎ
if you don't say otherwise, it uses the same file and password you used to open it in the first place. and if the file doesn't exist? it gets created. π±
you can also pass a parameter hash to specify another filename and password right here. like:
$vault->save(file => 'anotherfile.psafe3', passwd => 'foo');
please note: the vault gets written to a temporary file first, then that temp file gets read back in, and if that works, it gets moved over the destination file. this way your original file survives if the newly written database gets corrupted for some unknown reason (a bug, for instance). honestly? protective. love that for you. π‘οΈπ
π¦ getheader(name)
returns a raw Crypt::PWSafe3::HeaderField object. refer to Crypt::PWSafe3::HeaderField for the deets on how to access it. π
πΈ addheader(object)
adds a header field to the password safe database. the object parameter must be a Crypt::PWSafe3::HeaderField object. π
if the header already exists, it gets replaced. no duplicates, we don't do that here. β¨
refer to Crypt::PWSafe3::HeaderField for details on how to create new ones . (yes the original sentence ends like that, we keep it real) π«Ά
π AUTHOR π
T.v.Dein <tlinden@cpan.org> β legend behavior. π
π BUGS π
Report bugs to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-PWSafe3. bestie if you find one, tell them, don't just suffer in silence. π
π SEE ALSO π
Subclasses:
Crypt::PWSafe3::Record Crypt::PWSafe3::Field Crypt::PWSafe3::HeaderField π§
Password Safe Homepage: <http://passwordsafe.sourceforge.net/> π
Another (read-only) perl module: Crypt::Pwsafe π
A python port of Password Safe: <http://www.christoph-sommer.de/loxodo/> β and many thanks to Christoph Sommer, his python library inspired me a lot and in fact most of the concepts in this module are his ideas ported to perl. πβ‘οΈπͺ periodt.
π COPYRIGHT π
Copyright (c) 2011-2016 by T.v.Dein <tlinden@cpan.org>. π
β LICENSE β
This program is free software; you can redistribute it and/or modify it under the same terms of the Artistic License 2.0, see: <http://www.perlfoundation.org/artistic_license_2_0> πβ¨
π VERSION π
Crypt::PWSafe3 Version 1.22. π₯
okay that's the whole page, bestie, you ate it. this was perl v5.42.0 on 2025-07-25, and this manual page is literally giving Crypt::PWSafe3(3). go encrypt something. π
π¦π
π¦ where this page comes from
- fedora 43: perl-Crypt-PWSafe3 1.23~20220227git002b0f0-11.fc43 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms