53 lines
2.4 KiB
C++
53 lines
2.4 KiB
C++
#ifndef PASSMAN_H
|
|
#define PASSMAN_H
|
|
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <QString>
|
|
#include <QCryptographicHash>
|
|
#include <QRandomGenerator>
|
|
#include <QFile>
|
|
#include <QStandardPaths>
|
|
#include <QRandomGenerator>
|
|
#include "qaesencryption.h"
|
|
|
|
class passman
|
|
{
|
|
public:
|
|
passman();
|
|
QString database_path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/credentials.database";
|
|
QString key = "";
|
|
void save() const;
|
|
bool load();
|
|
void encrypt();
|
|
bool decrypt();
|
|
bool backup() const;
|
|
void add_entry(QString website_name, QString username, QString password, QString note);
|
|
void remove_entry(int index);
|
|
void alter_entry(int index, QString new_website_name, QString new_username, QString new_password, QString new_note);
|
|
void clear_database();
|
|
std::array<QString, 4> get_entry_copy(int index) const;
|
|
std::vector<std::array<QString, 4>> get_database_copy() const;
|
|
QString generate_password(int length) const;
|
|
bool database_exists() const;
|
|
|
|
protected:
|
|
QAESEncryption *encryption;
|
|
QByteArray encrypted_data; //Encrypted Database
|
|
std::vector<std::array<QString, 4>> decrypted_entries; //Database Entries
|
|
QString characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:;.,/=-+*<>{}()[]_%#$@!?^&";
|
|
QStringList ivs = {
|
|
"jW2jT]%0k2#-2R1.d(7'6V0Z|4=-HX2G9@F;561.07@21,NHq42)*896M(18R+9w080*Hs^,45G?;]5R7}'*0Z67?Y7|%SFI**0g",
|
|
")OR2*711+M)*a,5D/qB}/#]|fN*30oA<#;>]B80>,4J9@<<;J5;#wL*]p$G9D0i1860;Y<I*.)0diN/yi*08;^hJ596]2NY9&+#l",
|
|
"J>}b;|h)]6h6.O(n(*R)j87WrfZJ%>DM635u68i/s7@<*=/[V562&46E}P)/+8pZ$0c/3)690A/t.8eJ+4gJxf1&q?99%AP{)c71",
|
|
"6J00^0c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