Crypt::PWSafe3(3)

πŸ“¦
version 1.23~20220227git002b0f0 Β· 2 versions
, in fedora 43

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 call save(). πŸŽ€
  • 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 variable USER gets used when you call save(). πŸ’…
  • program β€” says which program saved the password safe file. skip it and the contents of the perl variable $0 get used, which is the name of the currently running script. ✨
  • create β€” if it's set to 0, 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 by getrecords() are still associated with the Crypt::PWSafe3 object. 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 (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