Compare commits

..

No commits in common. "5a69369fdd5ff0856b12ea7de9b908624a9634a1" and "a1e8d7ab9006a0686c3f3390721f3b9dde722556" have entirely different histories.

22 changed files with 53 additions and 123 deletions

0
LICENSE Executable file → Normal file
View file

2
PKGBUILD_amd64 Executable file → Normal file
View file

@ -1,5 +1,5 @@
pkgname=passman
pkgver=1.0.4
pkgver=1.0.2
pkgrel=1
pkgdesc="A Simple Password Manager with AES-256 Encryption"
arch=('x86_64')

2
PKGBUILD_arm64 Executable file → Normal file
View file

@ -1,5 +1,5 @@
pkgname=passman
pkgver=1.0.4
pkgver=1.0.2
pkgrel=1
pkgdesc="A Simple Password Manager with AES-256 Encryption"
arch=('aarch64')

2
README.md Executable file → Normal file
View file

@ -2,7 +2,7 @@
A Simple Password Manager with AES-256 Encryption<br />
Files **qaesencryption.cpp** and **qaesencryption.h** are from [This Repo](https://github.com/bricke/Qt-AES)
Version 1.0.4<br />
Version 1.0.2<br />
![screenshot.png](screenshot.png)

2
control_amd64 Executable file → Normal file
View file

@ -1,5 +1,5 @@
Package: passman
Version: 1.0.4
Version: 1.0.2
Section: utils
Priority: optional
Architecture: amd64

2
control_arm64 Executable file → Normal file
View file

@ -1,5 +1,5 @@
Package: passman
Version: 1.0.4
Version: 1.0.2
Section: utils
Priority: optional
Architecture: arm64

14
main.cpp Executable file → Normal file
View file

@ -6,9 +6,8 @@
int main(int argc, char *argv[])
{
QString version = "1.0.4";
QString version = "1.0.2";
//Run GUI if no arguments are passed
if (argc == 1)
{
QApplication a(argc, argv);
@ -26,7 +25,6 @@ int main(int argc, char *argv[])
parameterparser parameter_parser(argc, argv);
passman password_manager;
//Print help ccreen
if (parameter_parser.has_parameter("help", 'h'))
{
std::cout << "Passman v" << version.toStdString() << " - A Simple Password Manager with AES-256 Encryption by Aslan2142\n\n";
@ -48,17 +46,13 @@ int main(int argc, char *argv[])
return 0;
}
//Load password from an argument (if present)
std::string password = parameter_parser.get_value("pass", 'p');
//Wait for password input in case it wasn't present in the argument
if (password.compare("-") == 0)
{
std::cout << "Input Pasword: ";
std::cin >> password;
}
password_manager.key = QString::fromStdString(password);
//Create database
if (parameter_parser.has_parameter("create-database", 'd'))
{
if (password_manager.database_exists())
@ -77,7 +71,6 @@ int main(int argc, char *argv[])
}
}
//Print main errors (if occured)
if (!password_manager.load())
{
std::cerr << "Error Loading Database" << std::endl;
@ -89,7 +82,6 @@ int main(int argc, char *argv[])
return 2;
}
//Create new entry
std::string new_entry = parameter_parser.get_value("new", 'n');
if (new_entry.compare("-") != 0)
{
@ -106,7 +98,6 @@ int main(int argc, char *argv[])
password_manager.save();
}
//Remove an entry
std::string remove_entry = parameter_parser.get_value("remove", 'r');
if (remove_entry.compare("-") != 0)
{
@ -140,13 +131,11 @@ int main(int argc, char *argv[])
password_manager.save();
}
//Backup database
if (parameter_parser.has_parameter("backup", 'b'))
{
password_manager.backup();
}
//Show all entries
if (parameter_parser.has_parameter("show-all", 'a'))
{
const std::vector<std::array<QString, 4>> database = password_manager.get_database_copy();
@ -156,7 +145,6 @@ int main(int argc, char *argv[])
}
}
//Search and show entries by website
std::string show_website = parameter_parser.get_value("show", 's');
if (show_website.compare("-") != 0)
{

77
mainwindow.cpp Executable file → Normal file
View file

@ -26,7 +26,7 @@ MainWindow::~MainWindow()
void MainWindow::decrypt_database()
{
//Load and decrypt database
//Load and Decrypt Database
password_manager.key = ui->lineEditEncryptionKey->text();
if (!password_manager.load())
@ -45,7 +45,7 @@ void MainWindow::decrypt_database()
ui->labelDatabaseInfo->setText("Database Loaded");
ui->labelEncryptionInfo->setText("Database Decrypted");
//Fill up the table
//Fill up the Table
std::vector<std::array<QString, 4>> database = password_manager.get_database_copy();
ui->tableWidgetCredentials->clear();
@ -62,7 +62,7 @@ void MainWindow::decrypt_database()
saved = true;
//Enable/Disable UI elements
//Enable/Disable UI Elements
ui->pushButtonUnlock->setEnabled(false);
ui->lineEditEncryptionKey->setEnabled(false);
@ -75,16 +75,12 @@ void MainWindow::decrypt_database()
ui->lineEditSearch->setEnabled(true);
ui->tableWidgetCredentials->setEnabled(true);
//Set UI collumn names
ui->tableWidgetCredentials->setHorizontalHeaderLabels({"Website", "Username", "Password", "Note"});
ui->tableWidgetCredentials->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->lineEditSearch->setFocus();
}
void MainWindow::backup_database()
{
//Backup the database if it exists
if (password_manager.backup())
{
ui->labelDatabaseInfo->setText("Database Backup Complete");
@ -95,22 +91,18 @@ void MainWindow::backup_database()
void MainWindow::save_database()
{
//Clear old database data
password_manager.clear_database();
std::array<QString, 4> tmp_row;
for (int i = 0; i < ui->tableWidgetCredentials->rowCount(); i++)
{
//Get the data from the row
for (int j = 0; j < 4; j++)
{
tmp_row[static_cast<ulong>(j)] = ui->tableWidgetCredentials->item(i, j)->text();
}
//Add the row data to the database
password_manager.add_entry(tmp_row[0], tmp_row[1], tmp_row[2], tmp_row[3]);
}
//Encrypt and save the database onto a drive
password_manager.encrypt();
password_manager.save();
@ -121,13 +113,12 @@ void MainWindow::add_entry()
{
int row_count = ui->tableWidgetCredentials->rowCount();
//Add the entry to the end of the database and scroll to the row
ui->tableWidgetCredentials->insertRow(row_count);
ui->tableWidgetCredentials->scrollToItem(ui->tableWidgetCredentials->takeItem(row_count, 0));
ui->tableWidgetCredentials->setItem(row_count, 0, new QTableWidgetItem(""));
ui->tableWidgetCredentials->setItem(row_count, 1, new QTableWidgetItem(""));
ui->tableWidgetCredentials->setItem(row_count, 2, new QTableWidgetItem(password_manager.generate_password(password_length))); //Add generated password
ui->tableWidgetCredentials->setItem(row_count, 2, new QTableWidgetItem(password_manager.generate_password(password_length)));
ui->tableWidgetCredentials->setItem(row_count, 3, new QTableWidgetItem(""));
saved = false;
@ -135,27 +126,10 @@ void MainWindow::add_entry()
void MainWindow::remove_entry()
{
//Get a list of selected database entries
QList<QTableWidgetItem*> selected = ui->tableWidgetCredentials->selectedItems();
if (selected.size() > 0)
{
saved = false;
}
saved = selected.size() <= 0;
//Get rid of item duplicates caused by multiple collumns
int last_row = -1;
for (int i = 0; i < selected.size(); i++)
{
if (last_row == selected[i]->row())
{
selected.removeAt(i--);
continue;
}
last_row = selected[i]->row();
}
//Remove all selected rows
for (QTableWidgetItem* item : selected)
{
ui->tableWidgetCredentials->removeRow(item->row());
@ -164,27 +138,10 @@ void MainWindow::remove_entry()
void MainWindow::generate_password()
{
//Get a list of selected database entries
QList<QTableWidgetItem*> selected = ui->tableWidgetCredentials->selectedItems();
if (selected.size() > 0)
{
saved = false;
}
saved = selected.size() <= 0;
//Get rid of item duplicates caused by multiple collumns
int last_row = -1;
for (int i = 0; i < selected.size(); i++)
{
if (last_row == selected[i]->row())
{
selected.removeAt(i--);
continue;
}
last_row = selected[i]->row();
}
//Generate new password for all selected rows
for (QTableWidgetItem* item : selected)
{
ui->tableWidgetCredentials->setItem(item->row(), 2, new QTableWidgetItem(password_manager.generate_password(password_length)));
@ -217,7 +174,6 @@ void MainWindow::search(const QString &input)
void MainWindow::closeEvent(QCloseEvent *event)
{
//Close the program if the newest database is saved, if not show a dialog
if (saved)
{
event->accept();
@ -250,18 +206,17 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::check_database()
{
if (password_manager.database_exists())
{
return;
}
//Show new database dialog
QInputDialog input_dialog;
input_dialog.resize(400, 200);
input_dialog.setWindowTitle("Database not Found");
input_dialog.setLabelText("Enter Password for your new Database:");
//Close the dialog
if (input_dialog.exec() == 0)
{
close();
@ -277,7 +232,6 @@ void MainWindow::check_database()
password_manager.save();
}
//Recheck to see if a new database has been created
check_database();
}
@ -288,25 +242,12 @@ void MainWindow::on_spinBoxPasswordLength_valueChanged(int arg1)
void MainWindow::on_tableWidgetCredentials_itemChanged()
{
saved = false; //Set save indicator to false if database entry has been changed
saved = false;
}
void MainWindow::on_tableWidgetCredentials_itemSelectionChanged()
{
//Get a list of selected database entries
QList<QTableWidgetItem*> selected = ui->tableWidgetCredentials->selectedItems();
int count = 0;
int last_row = -1;
//Count the number of entries
for (QTableWidgetItem* item : selected)
{
if (last_row != item->row()) count++; //Count only rows(entries) and not the collumns
last_row = item->row();
}
//Set the remove entry button text according to number of selected entries
if (count > 1)
if (ui->tableWidgetCredentials->selectedItems().size() > 1)
{
ui->pushButtonRemoveEntry->setText("Remove Selected Entries");
} else {

30
mainwindow.h Executable file → Normal file
View file

@ -19,27 +19,27 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QString version, QWidget *parent = nullptr);
~MainWindow() override;
void check_database(); //Shows dialog to make a new database if it doesn't exist
void check_database();
protected:
passman password_manager; //Password manager object
bool saved = true; //Indicates if all the database changes has been saved
int password_length = 20; //Used by the password generator
void closeEvent(QCloseEvent *event) override; //Executes when user tries to close the app
passman password_manager;
bool saved = true;
int password_length = 20;
void closeEvent(QCloseEvent *event) override;
protected slots:
void decrypt_database(); //Executes when user clicks on decrypt database button
void backup_database(); //Executes when user clicks on backup database button
void save_database(); //Executes when user clicks on save database button
void add_entry(); //Executes when user clicks on add entry button
void remove_entry(); //Executes when user clicks on remove entry button
void generate_password(); //Executes when user clicks on generate password button
void search(const QString &input); //Executes when user changes
void decrypt_database();
void backup_database();
void save_database();
void add_entry();
void remove_entry();
void generate_password();
void search(const QString &input);
private slots:
void on_spinBoxPasswordLength_valueChanged(int arg1); //Executes when password length spinbox has been changed
void on_tableWidgetCredentials_itemChanged(); //Executes when database entry has been changed
void on_tableWidgetCredentials_itemSelectionChanged(); //Executes when database entry selection has been changed
void on_spinBoxPasswordLength_valueChanged(int arg1);
void on_tableWidgetCredentials_itemChanged();
void on_tableWidgetCredentials_itemSelectionChanged();
private:
Ui::MainWindow *ui;

0
mainwindow.ui Executable file → Normal file
View file

0
makearchpkg.sh Executable file → Normal file
View file

0
makedebpkg.sh Executable file → Normal file
View file

0
parameterparser.cpp Executable file → Normal file
View file

3
parameterparser.h Executable file → Normal file
View file

@ -4,7 +4,6 @@
#include <string>
#include <vector>
//Help to manage the program input parameters
class parameterparser
{
public:
@ -14,7 +13,7 @@ public:
protected:
std::vector<std::string> arg_names;
std::vector<std::string> arg_values;
void parse(int argc, char *argv[]); //Parse the parameters and insert values into vectors of string
void parse(int argc, char *argv[]);
};
#endif // PARAMETERPARSER_H

7
passman.cpp Executable file → Normal file
View file

@ -2,6 +2,7 @@
passman::passman() : encryption(new QAESEncryption(QAESEncryption::AES_256, QAESEncryption::CBC)) { }
//Save Database to Disk
void passman::save() const
{
QFile output_file(database_path);
@ -10,6 +11,7 @@ void passman::save() const
output_file.close();
}
//Load Database from Disk
bool passman::load()
{
if (!database_exists())
@ -25,6 +27,7 @@ bool passman::load()
return true;
}
//Encrypt Database
void passman::encrypt()
{
QByteArray data = QString("passwords\n").toLocal8Bit();
@ -34,8 +37,6 @@ void passman::encrypt()
{
for (QString& entry_column : entry_row)
{
entry_column = entry_column.replace("\n", "");
entry_column = entry_column.replace("\t", "");
data.append((entry_column + '\t').toLocal8Bit());
}
data.append(QString('\n').toLocal8Bit());
@ -49,6 +50,7 @@ void passman::encrypt()
encrypted_data = data;
}
//Decrypt Database
bool passman::decrypt()
{
QByteArray data = encrypted_data;
@ -94,6 +96,7 @@ bool passman::decrypt()
return stringData.startsWith("password");
}
//Make Database Backup
bool passman::backup() const
{
if (!database_exists())

35
passman.h Executable file → Normal file
View file

@ -3,7 +3,6 @@
#include <iostream>
#include <vector>
#include <array>
#include <QString>
#include <QCryptographicHash>
#include <QRandomGenerator>
@ -17,26 +16,26 @@ class passman
public:
passman();
QString database_path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/credentials.database";
QString key = ""; //Database encryption key
void save() const; //Save the database to the database path on drive
bool load(); //Loads the database from the database path on a drive
void encrypt(); //Encrypts database entries into encrypted data
bool decrypt(); //Decrypts encrypted database data into database entries
bool backup() const; //Backups the database in a backup location on a drive and returns false if there is not a database to backup
void add_entry(QString website_name, QString username, QString password, QString note); //Add new entry to database
void remove_entry(int index); //Return entry from a database
void alter_entry(int index, QString new_website_name, QString new_username, QString new_password, QString new_note); //Alter database entry
void clear_database(); //Removes everything from the database
std::array<QString, 4> get_entry_copy(int index) const; //Returns entry copy from the database
std::vector<std::array<QString, 4>> get_database_copy() const; //Returns full database copy
QString generate_password(int length) const; //Returns newly generated password string
bool database_exists() const; //Returns true if database exists on a drive in certain location
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; //Pointer to an object used for encryption
QAESEncryption *encryption;
QByteArray encrypted_data; //Encrypted Database
std::vector<std::array<QString, 4>> decrypted_entries; //Database Entries
QString characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:;.,/=-+*<>{}()[]_%#$@!?^&"; //List of characters for password generator
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",
@ -48,7 +47,7 @@ protected:
"72|/3;10O@!(|t)]8}02Gf126N)+6*w6e2P57/dWd*JW5+aR?h31e/=4o5<H@Uzu2<;71Qd63B{k9-PQ_41[5yA'e^?2A27$[8-7",
"H(6>8!$l9!4?6_,7L%4}z3Lu8;sb^q}9%lVy6I57L]8<,-ho?310Dd_h|y1#iz%3]rN'zr5T1Bc2uQ5cb!K39386)50c0+%.w.X'",
"2-n$rL3v4T/*/22F%2tN}.yDX78#50z3Z9-B10X5*4]97+R-OK'2^F%7$>95c8jLu531C==1|V7Cd=o;5L6/B17jF2C9<1]R4'DY",
}; //List of initialization vectors for aes encryption/decryption
};
};
#endif // PASSMAN_H

0
passman.pro Executable file → Normal file
View file

0
passman_icon.svg Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before After
Before After

0
qaesencryption.cpp Executable file → Normal file
View file

0
qaesencryption.h Executable file → Normal file
View file

0
resources.qrc Executable file → Normal file
View file

0
screenshot.png Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 302 KiB

After

Width:  |  Height:  |  Size: 302 KiB

Before After
Before After