File::...y::File(3pm)

πŸ“¦
version 0.906 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– File::KDBX::Key::File β€” a file key πŸ’–

okay bestie, this page lives in the File::KDBX::Key::File manual, part of the User Contributed Perl Documentation, and it's about the kind of key that's literally just... a file. no cap.


✨ VERSION ✨

version 0.906 β€” she's giving stable, she's giving released 🫢


✨ SYNOPSIS ✨

use File::KDBX::Constants qw(:key_file);
use File::KDBX::Key::File;

### Create a key file:

my $key = File::KDBX::Key::File->new(
    filepath    => 'path/to/file.keyx',
    type        => KEY_FILE_TYPE_XML,   # optional
    version     => 2,                   # optional
    raw_key     => $raw_key,            # optional - leave undefined to generate a random key
);
$key->save;

### Use a key file:

my $key2 = File::KDBX::Key::File->new('path/to/file.keyx');
# OR
my $key2 = File::KDBX::Key::File->new(\$secret);
# OR
my $key2 = File::KDBX::Key::File->new($fh); # or *IO

🌸 DESCRIPTION 🌸

so a file key (aka a "key file", we been knew) is the type of key where the secret is a file. the secret is either the file contents, or it's generated based on the file contents. to lock and unlock a KDBX database with a key file, you have to present the exact same file. girl, the database literally cannot be opened without it. no file, no entry, periodt. πŸ”’

it inherits methods and attributes from File::KDBX::Key (the original text says "Inherets", and honestly? iconic typo, we love her, but the meaning stands πŸ’…).

there are multiple types of key files supported β€” go peek at "type" below. this module can read and write key files. versatile queen. πŸ‘‘


πŸ’… ATTRIBUTES πŸ’…

✨ type

$type = $key->type;

gets the type of key file. it can be one of these, from ":key_file" in File::KDBX::Constants:

  • "KEY_FILE_TYPE_BINARY"
  • "KEY_FILE_TYPE_HEX"
  • "KEY_FILE_TYPE_XML"
  • "KEY_FILE_TYPE_HASHED"

✨ version

$version = $key->version;

gets the file version. heads up: this only applies to XML key files. everyone else can sit down bestie πŸͺ‘

✨ filepath

$filepath = $key->filepath;

gets the filepath to the key file, if known. if not known... mystery. 🀫


πŸ”₯ METHODS πŸ”₯

🌈 load

$key = $key->load($filepath);
$key = $key->load(\$string);
$key = $key->load($fh);
$key = $key->load(*IO);

loads a key file. look at all those ways to hand her the goods β€” a path, a scalar ref, a filehandle, a glob. main character energy fr fr. ⭐

🌈 reload

$key->reload;

re-reads the key file, if possible, and updates the raw key if the key changed. like a vibe check on your key, but it actually updates state. πŸ¦‹

🌈 save

$key->save;
$key->save(%options);

writes a key file. available options, bestie:

  • "type" β€” type of key file (default: the value of "type", or "KEY_FILE_TYPE_XML")
  • "verson" β€” version of key file (default: the value of "version", or 2). yes, it's spelled verson in here, that's not me, that's the source, we don't ask questions πŸ™ˆ
  • "filepath" β€” where to save the file (default: the value of "filepath")
  • "fh" β€” IO handle to write to (this overrides "filepath", and one of the two must be defined)
  • "raw_key" β€” raw key (default: the value of "raw_key")
  • "atomic" β€” write to the filepath atomically (default: true) β€” no half-written key files, we're not doing chaos today ✨

πŸ’€ BUGS πŸ’€

please report any bugs or feature requests on the bugtracker website <https://github.com/chazmcgarvey/File-KDBX/issues> β€” go off, tell them everything 🫢

when submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. receipts, bestie. give them receipts. 🧾


πŸ‘‘ AUTHOR πŸ‘‘

Charles McGarvey <ccm@cpan.org>


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. slay, legally speaking. πŸ’œ


and that's the whole page, babes β€” this one's documented against perl v5.40.1, dated 2025-05-04, under the manual name File::...y::File(3pm) (yes, truncated, mystery-core, we love that for her πŸ’–βœ¨). now go lock something up properly. πŸ’…

πŸ“¦ where this page comes from