Passwordfile library  3.1.2
C++ library to read/write passwords from/to encrypted files
passwordfile.h
Go to the documentation of this file.
1 #ifndef PASSWORDFILE_H
2 #define PASSWORDFILE_H
3 
4 #include "../global.h"
5 
6 #include <c++utilities/io/binaryreader.h>
7 #include <c++utilities/io/binarywriter.h>
8 
9 #include <string>
10 #include <iostream>
11 #include <fstream>
12 #include <memory>
13 
14 namespace Io {
15 
16 class NodeEntry;
17 
19 {
20 public:
21  explicit PasswordFile();
22  explicit PasswordFile(const std::string &path, const std::string &password);
23  PasswordFile(const PasswordFile &other);
24  ~PasswordFile();
25  void open(bool readOnly = false);
26  void generateRootEntry();
27  void create();
28  void close();
29  void load();
30  void save(bool useEncryption = true, bool useCompression = true);
31  void clearEntries();
32  void clear();
33  void exportToTextfile(const std::string &targetPath) const;
34  void doBackup();
35  bool hasRootEntry() const;
36  const NodeEntry *rootEntry() const;
37  NodeEntry *rootEntry();
38  const std::string &path() const;
39  const char *password() const;
40  void setPath(const std::string &value);
41  void clearPath();
42  void setPassword(const std::string &value);
43  void clearPassword();
44  bool isEncryptionUsed();
45  bool isOpen() const;
46  size_t size();
47 private:
48  std::string m_path;
49  char m_password[32];
50  std::unique_ptr<NodeEntry> m_rootEntry;
51  std::string m_extendedHeader;
52  std::string m_encryptedExtendedHeader;
53  std::fstream m_file;
54  IoUtilities::BinaryReader m_freader;
55  IoUtilities::BinaryWriter m_fwriter;
56 };
57 
58 }
59 
60 #endif // PASSWORDFILE_H
The NodeEntry class acts as parent for other entries.
Definition: entry.h:97
The PasswordFile class holds account information in the form of Entry and Field instances and provide...
Definition: passwordfile.h:18
Contains all IO related classes.
#define PASSWORD_FILE_EXPORT
Definition: global.h:13