File::KDBX::Safe(3pm)
π File::KDBX::Safe π
okay bestie, so this is a page from the User Contributed Perl Documentation set β that's the posh name for the perldoc manual File::KDBX::Safe(3pm). It lives on your system as a perl manpage, and I'm about to make it make sense.
β¨ NAME β¨
File::KDBX::Safe β keeps your strings encrypted while they're just vibing in memory. π
πΈ VERSION πΈ
This is version 0.906, bestie. Noted. Periodt.
π¦ SYNOPSIS π¦
use File::KDBX::Safe;
$safe = File::KDBX::Safe->new;
my $msg = 'Secret text';
$safe->add(\$msg);
# $msg is now undef, the original message no longer in RAM
my $obj = { value => 'Also secret' };
$safe->add($obj);
# $obj is now { value => undef }
say $safe->peek($msg); # Secret text
$safe->unlock;
say $msg; # Secret text
say $obj->{value}; # Also secret
likeβ¦ look at her go. π«Ά
π DESCRIPTION π
This module is all about memory protection, and no cap, that's the whole point. It keeps strings encrypted while they're sitting in memory and only decrypts them on an as-needed basis. The encryption and decryption heavy lifting is done by a File::KDBX::Cipher::Stream. π
One safe can protect one string, or a bunch of them β like, seriously, as many as you want. When you add a string to a safe, it gets tossed onto an internal list, and that list is the thing that gets decrypted when you unlock the whole entire safe. it's giving β¨organizedβ¨.
π ATTRIBUTES π
π cipher
$cipher = $safe->cipher;
Get the File::KDBX::Cipher::Stream that's protecting a safe. that's it, that's the whole attribute. iconic.
π₯ METHODS π₯
β new
$safe = File::KDBX::Safe->new(%attributes);
$safe = File::KDBX::Safe->new(\@strings, %attributes);
Make yourself a brand new safe for storing secret strings encrypted in memory. π§
If you pass a cipher in, its stream will be reset. just so you know.
π clear
$safe = $safe->clear;
Clear out a safe β removes all the store contents, and it's permanent, bestie, no take-backs. π
It returns itself so you can chain methods like the main character you are.
π lock
π add
$safe = $safe->lock(@strings);
$safe = $safe->lock(\@strings);
Add one or more strings to the memory protection stream. Returns itself, chaining enabled, slay. π
π lock_protected
π add_protected
$safe = $safe->lock_protected(@strings);
$safe = $safe->lock_protected(\@strings);
Add strings that are already encrypted. Returns itself to allow method chaining, obviously.
β οΈ WARNING, and I mean it: the cipher has to be the same one that was used to originally encrypt those strings. And you must add already-encrypted strings in the exact order in which they were originally encrypted, or they will not decrypt correctly. no shade, it just will not work. Also β you almost certainly do not want to add both unprotected and protected strings to the same safe. pick a lane bestie. π«
π unlock
$safe = $safe->unlock;
Decrypt all the strings. Each stored string gets set back to its original value, which could potentially overwrite whatever value got set after you locked the string β so yeah, you probably should avoid modifying strings while they're locked. π
The safe is implicitly cleared. Returns itself to allow method chaining.
fun fact: this happens automatically when the safe gets garbage-collected. the safe cleans up after herself, as she should. β¨
π peek
$string_value = $safe->peek($string);
...
erase $string_value;
Peek into the safe at one particular string without decrypting the whole entire safe. You get back a copy of the string, and to keep the integrity of your memory protection intact, you should erase that copy when you're done with it. don't leave it lying around. π
Returns undef if the $string you gave it isn't in memory protection.
π BUGS π
Found a bug? Want a feature? Please report it on the bugtracker website:
https://github.com/chazmcgarvey/File-KDBX/issues
And when you submit that bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or the desired feature. receipts, bestie, we need receipts. π«Ά
π AUTHOR π
Charles McGarvey <ccm@cpan.org> β the icon behind all this. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2022 by Charles McGarvey.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
aaaand that's the whole page! π this wasperl v5.40.1, dated2025-05-04, from theFile::KDBX::Safe(3pm)manual. go forth and keep your secrets encrypted, bestie. π¦πβ¨
π¦ where this page comes from
- debian trixie: libfile-kdbx-perl 0.906-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libfile-kdbx-perl 0.906-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfile-kdbx-perl 0.906-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms