diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/kdbx-extract.cpp | 20 | ||||
-rw-r--r-- | utils/kdbx-merge.cpp | 29 |
2 files changed, 8 insertions, 41 deletions
diff --git a/utils/kdbx-extract.cpp b/utils/kdbx-extract.cpp index f5d2a19a6..6116b0365 100644 --- a/utils/kdbx-extract.cpp +++ b/utils/kdbx-extract.cpp @@ -33,8 +33,8 @@ int main(int argc, char **argv) { QCoreApplication app(argc, argv); - if (app.arguments().size() != 3) { - qCritical("Usage: kdbx-extract <password/key file> <kdbx file>"); + if (app.arguments().size() != 2) { + qCritical("Usage: kdbx-extract <kdbx file>"); return 1; } @@ -42,19 +42,11 @@ int main(int argc, char **argv) qFatal("Fatal error while testing the cryptographic functions:\n%s", qPrintable(Crypto::errorString())); } - CompositeKey key; - if (QFile::exists(app.arguments().at(1))) { - FileKey fileKey; - fileKey.load(app.arguments().at(1)); - key.addKey(fileKey); - } - else { - PasswordKey password; - password.setPassword(app.arguments().at(1)); - key.addKey(password); - } + static QTextStream inputTextStream(stdin, QIODevice::ReadOnly); + QString line = inputTextStream.readLine(); + CompositeKey key = CompositeKey::readFromLine(line); - QFile dbFile(app.arguments().at(2)); + QFile dbFile(app.arguments().at(1)); if (!dbFile.exists()) { qCritical("File does not exist."); return 1; diff --git a/utils/kdbx-merge.cpp b/utils/kdbx-merge.cpp index d67a87672..da780ea1b 100644 --- a/utils/kdbx-merge.cpp +++ b/utils/kdbx-merge.cpp @@ -29,31 +29,6 @@ #include "format/KeePass2Reader.h" #include "format/KeePass2Writer.h" #include "keys/CompositeKey.h" -#include "keys/FileKey.h" -#include "keys/PasswordKey.h" - -/* - * Read a key from a line of input. - * If the line references a valid file - * path, the key is loaded from file. - */ -CompositeKey readKeyFromLine(QString line) -{ - - CompositeKey key; - if (QFile::exists(line)) { - FileKey fileKey; - fileKey.load(line); - key.addKey(fileKey); - } - else { - PasswordKey password; - password.setPassword(line); - key.addKey(password); - } - return key; - -} int main(int argc, char **argv) { @@ -85,7 +60,7 @@ int main(int argc, char **argv) static QTextStream inputTextStream(stdin, QIODevice::ReadOnly); QString line1 = inputTextStream.readLine(); - CompositeKey key1 = readKeyFromLine(line1); + CompositeKey key1 = CompositeKey::readFromLine(line1); CompositeKey key2; if (parser.isSet("same-password")) { @@ -93,7 +68,7 @@ int main(int argc, char **argv) } else { QString line2 = inputTextStream.readLine(); - key2 = readKeyFromLine(line2); + key2 = CompositeKey::readFromLine(line2); } |