1File::KDBX::Key::File(3U)ser Contributed Perl DocumentatiFoinle::KDBX::Key::File(3)
2
3
4
6 File::KDBX::Key::File - A file key
7
9 version 0.906
10
12 use File::KDBX::Constants qw(:key_file);
13 use File::KDBX::Key::File;
14
15 ### Create a key file:
16
17 my $key = File::KDBX::Key::File->new(
18 filepath => 'path/to/file.keyx',
19 type => KEY_FILE_TYPE_XML, # optional
20 version => 2, # optional
21 raw_key => $raw_key, # optional - leave undefined to generate a random key
22 );
23 $key->save;
24
25 ### Use a key file:
26
27 my $key2 = File::KDBX::Key::File->new('path/to/file.keyx');
28 # OR
29 my $key2 = File::KDBX::Key::File->new(\$secret);
30 # OR
31 my $key2 = File::KDBX::Key::File->new($fh); # or *IO
32
34 A file key (or "key file") is the type of key where the secret is a
35 file. The secret is either the file contents or is generated based on
36 the file contents. In order to lock and unlock a KDBX database with a
37 key file, the same file must be presented. The database cannot be
38 opened without the file.
39
40 Inherets methods and attributes from File::KDBX::Key.
41
42 There are multiple types of key files supported. See "type". This
43 module can read and write key files.
44
46 type
47 $type = $key->type;
48
49 Get the type of key file. Can be one of from ":key_file" in
50 File::KDBX::Constants:
51
52 • "KEY_FILE_TYPE_BINARY"
53
54 • "KEY_FILE_TYPE_HEX"
55
56 • "KEY_FILE_TYPE_XML"
57
58 • "KEY_FILE_TYPE_HASHED"
59
60 version
61 $version = $key->version;
62
63 Get the file version. Only applies to XML key files.
64
65 filepath
66 $filepath = $key->filepath;
67
68 Get the filepath to the key file, if known.
69
71 load
72 $key = $key->load($filepath);
73 $key = $key->load(\$string);
74 $key = $key->load($fh);
75 $key = $key->load(*IO);
76
77 Load a key file.
78
79 reload
80 $key->reload;
81
82 Re-read the key file, if possible, and update the raw key if the key
83 changed.
84
85 save
86 $key->save;
87 $key->save(%options);
88
89 Write a key file. Available options:
90
91 • "type" - Type of key file (default: value of "type", or
92 "KEY_FILE_TYPE_XML")
93
94 • "verson" - Version of key file (default: value of "version", or 2)
95
96 • "filepath" - Where to save the file (default: value of "filepath")
97
98 • "fh" - IO handle to write to (overrides "filepath", one of which
99 must be defined)
100
101 • "raw_key" - Raw key (default: value of "raw_key")
102
103 • "atomic" - Write to the filepath atomically (default: true)
104
106 Please report any bugs or feature requests on the bugtracker website
107 <https://github.com/chazmcgarvey/File-KDBX/issues>
108
109 When submitting a bug or request, please include a test-file or a patch
110 to an existing test-file that illustrates the bug or desired feature.
111
113 Charles McGarvey <ccm@cpan.org>
114
116 This software is copyright (c) 2022 by Charles McGarvey.
117
118 This is free software; you can redistribute it and/or modify it under
119 the same terms as the Perl 5 programming language system itself.
120
121
122
123perl v5.36.1 2023-09-27 File::KDBX::Key::File(3)