├── logo.png
├── src
├── ckicon.rc
├── bruce.png
├── logo.ico
├── logo.png
├── ckicons.icns
├── cryptoknife.ico
├── cryptoknife.png
├── cryptokniferes.qrc
├── main.cpp
├── globals.h
├── brucethepoodle.h
├── brucethepoodle.cpp
├── brucethepoodle.ui
├── crc32.h
├── Cryptoknife.pro
├── crypto.h
├── mainwindow.h
├── crc32.cpp
├── crypto.cpp
├── mainwindow.ui
└── mainwindow.cpp
├── logo32.png
├── encoding_tab.png
├── hashing_tab.png
├── icon_128x128.png
├── maclogo150.png
├── winlogo150.png
├── encryption_tab.png
├── utilities_tab.png
├── ci_cd
├── windows
│ ├── win-prebuild.bat
│ ├── win-deploy.bat
│ ├── win-build.bat
│ └── win-prebuild.php
└── mac
│ └── mac-build.sh
├── README.md
├── .gitignore
└── LICENSE
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/logo.png
--------------------------------------------------------------------------------
/src/ckicon.rc:
--------------------------------------------------------------------------------
1 | IDI_ICON1 ICON "logo.ico"
2 |
--------------------------------------------------------------------------------
/logo32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/logo32.png
--------------------------------------------------------------------------------
/src/bruce.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/src/bruce.png
--------------------------------------------------------------------------------
/src/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/src/logo.ico
--------------------------------------------------------------------------------
/src/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/src/logo.png
--------------------------------------------------------------------------------
/encoding_tab.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/encoding_tab.png
--------------------------------------------------------------------------------
/hashing_tab.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/hashing_tab.png
--------------------------------------------------------------------------------
/icon_128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/icon_128x128.png
--------------------------------------------------------------------------------
/maclogo150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/maclogo150.png
--------------------------------------------------------------------------------
/src/ckicons.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/src/ckicons.icns
--------------------------------------------------------------------------------
/winlogo150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/winlogo150.png
--------------------------------------------------------------------------------
/encryption_tab.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/encryption_tab.png
--------------------------------------------------------------------------------
/utilities_tab.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/utilities_tab.png
--------------------------------------------------------------------------------
/src/cryptoknife.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/src/cryptoknife.ico
--------------------------------------------------------------------------------
/src/cryptoknife.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dannagle/Cryptoknife/HEAD/src/cryptoknife.png
--------------------------------------------------------------------------------
/src/cryptokniferes.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | bruce.png
4 | logo.png
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ci_cd/windows/win-prebuild.bat:
--------------------------------------------------------------------------------
1 | set BUILD_VERSION=2.0.%BUILD_NUMBER%
2 | echo %BUILD_VERSION% > buildversion.txt
3 | REM copy /Y C:\Users\Dan\Desktop\prebuild-windows.php ci_cd\windows\win-prebuild.php
4 | C:\cygwin64\bin\php.exe ci_cd/windows/win-prebuild.php
5 |
--------------------------------------------------------------------------------
/ci_cd/windows/win-deploy.bat:
--------------------------------------------------------------------------------
1 | echo Building Installers
2 | set /p BUILD_VERSION=
13 |
14 | int main(int argc, char *argv[])
15 | {
16 | QApplication a(argc, argv);
17 | MainWindow w;
18 | w.show();
19 |
20 | return a.exec();
21 | }
22 |
--------------------------------------------------------------------------------
/ci_cd/windows/win-build.bat:
--------------------------------------------------------------------------------
1 | echo Making exe
2 | C:\Qt\5.12.0\mingw73_64\bin\qmake.exe -o Makefile src/Cryptoknife.pro -spec win32-g++
3 | C:\Qt\Tools\mingw730_64\bin\mingw32-make.exe -f Makefile.Release
4 | echo Signing exe
5 | cd release
6 | copy /Y C:\Users\Dan\Desktop\code_sign_exe_com.bat .
7 | call code_sign_exe_com.bat
8 | echo Copying signed exe
9 | copy /Y Cryptoknife.exe C:\Users\Dan\github\cryptoknifeinstaller\Cryptoknife\Cryptoknife.exe
10 |
--------------------------------------------------------------------------------
/src/globals.h:
--------------------------------------------------------------------------------
1 | #ifndef GLOBALS_H
2 | #define GLOBALS_H
3 |
4 | //BEGIN SW VERSION
5 | #define SW_VERSION "v2.0.1"
6 | //END SW VERSION
7 |
8 | //BEGIN FILE VERSION
9 | #define VER_FILEVERSION 2,0,1,0
10 | //END FILE VERSION
11 |
12 |
13 |
14 |
15 | #define QDEBUG() qDebug() << __FILE__ << "/" <<__LINE__ <<"(" << __FUNCTION__ << "):"
16 | #define QDEBUGVAR(var) QDEBUG() << # var << var;
17 |
18 | #define DATETIMEFORMAT "h:mm:ss.zzz ap"
19 |
20 |
21 | #endif // GLOBALS_H
22 |
--------------------------------------------------------------------------------
/src/brucethepoodle.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Packet Sender
3 | *
4 | * Licensed GPL v2
5 | * http://PacketSender.com/
6 | *
7 | * Copyright Dan Nagle
8 | *
9 | * (This is the dog easter egg.)
10 | *
11 | */
12 | #ifndef BRUCETHEPOODLE_H
13 | #define BRUCETHEPOODLE_H
14 |
15 | #include
16 |
17 | namespace Ui {
18 | class BruceThePoodle;
19 | }
20 |
21 | class BruceThePoodle : public QDialog
22 | {
23 | Q_OBJECT
24 |
25 | public:
26 | explicit BruceThePoodle(QWidget *parent = 0);
27 | ~BruceThePoodle();
28 |
29 | private:
30 | Ui::BruceThePoodle *ui;
31 | };
32 |
33 | #endif // BRUCETHEPOODLE_H
34 |
--------------------------------------------------------------------------------
/src/brucethepoodle.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Cryptoknife
3 | *
4 | * Licensed GPL v2
5 | * http://Cryptoknife.com/
6 | *
7 | * Copyright Dan Nagle
8 | *
9 | */
10 |
11 |
12 | #include "brucethepoodle.h"
13 | #include "ui_brucethepoodle.h"
14 |
15 | BruceThePoodle::BruceThePoodle(QWidget *parent) :
16 | QDialog(parent),
17 | ui(new Ui::BruceThePoodle)
18 | {
19 | ui->setupUi(this);
20 |
21 | Qt::WindowFlags flags = windowFlags();
22 | Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint;
23 | flags = flags & (~helpFlag);
24 | setWindowFlags(flags);
25 |
26 | this->setFixedSize(this->width(),this->height());
27 | setWindowTitle("Bruce The Poodle!");
28 | }
29 |
30 | BruceThePoodle::~BruceThePoodle()
31 | {
32 | delete ui;
33 | }
34 |
--------------------------------------------------------------------------------
/ci_cd/windows/win-prebuild.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | BruceThePoodle
4 |
5 |
6 |
7 | 0
8 | 0
9 | 768
10 | 768
11 |
12 |
13 |
14 |
15 | 0
16 | 0
17 |
18 |
19 |
20 |
21 | 768
22 | 768
23 |
24 |
25 |
26 |
27 | 768
28 | 768
29 |
30 |
31 |
32 | Dialog
33 |
34 |
35 | -
36 |
37 |
38 | background-image:url(:/bruce.png)
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/crc32.h:
--------------------------------------------------------------------------------
1 | /*
2 | The MIT License (MIT)
3 |
4 | Copyright (c) Alexander Nusov 2015
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 |
25 | #ifndef CRC32_H
26 | #define CRC32_H
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | class Crc32
33 | {
34 | private:
35 | quint32 crc_table[256];
36 | QMap instances;
37 |
38 | public:
39 | Crc32();
40 |
41 | quint32 calculateFromFile(QString filename);
42 |
43 | void initInstance(int i);
44 | void pushData(int i, char *data, int len);
45 | quint32 releaseInstance(int i);
46 | };
47 |
48 | #endif // CRC32_H
49 |
--------------------------------------------------------------------------------
/src/Cryptoknife.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2017-03-26T20:45:48
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui network
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10 |
11 | TARGET = Cryptoknife
12 | TEMPLATE = app
13 |
14 | # The following define makes your compiler emit warnings if you use
15 | # any feature of Qt which as been marked as deprecated (the exact warnings
16 | # depend on your compiler). Please consult the documentation of the
17 | # deprecated API in order to know how to port your code away from it.
18 | DEFINES += QT_DEPRECATED_WARNINGS
19 |
20 | # You can also make your code fail to compile if you use deprecated APIs.
21 | # In order to do so, uncomment the following line.
22 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
24 |
25 | # Yeah, yeah... I'm using 2 crypto libraries.
26 | # crypto++ is easier to use
27 |
28 |
29 | LIBS += -L$$PWD/../../cryptopp700/ -lcryptopp
30 | PRE_TARGETDEPS += $$PWD/../../cryptopp700/libcryptopp.a
31 |
32 | INCLUDEPATH += $$PWD/../../cryptopp700
33 | DEPENDPATH += $$PWD/../../cryptopp700
34 |
35 |
36 | macx:ICON = ckicons.icns
37 |
38 |
39 | win32:RC_FILE = ckicon.rc
40 |
41 | SOURCES += main.cpp\
42 | mainwindow.cpp \
43 | crypto.cpp \
44 | brucethepoodle.cpp \
45 | crc32.cpp
46 |
47 | HEADERS += mainwindow.h \
48 | crypto.h \
49 | globals.h \
50 | brucethepoodle.h \
51 | crc32.h
52 |
53 |
54 |
55 | FORMS += mainwindow.ui \
56 | brucethepoodle.ui
57 |
58 | RESOURCES += \
59 | cryptokniferes.qrc
60 |
--------------------------------------------------------------------------------
/ci_cd/mac/mac-build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ -z "$1" ]
4 | then
5 | echo "Please supply build version (e.g. 2.0.1)"
6 | exit
7 | fi
8 |
9 | if [ -z "$2" ]
10 | then
11 | echo "Please supply notary id username (e.g. apple@example.com)"
12 | exit
13 | fi
14 |
15 | if [ -z "$3" ]
16 | then
17 | echo "Please supply notary id password (e.g. hunter2)"
18 | exit
19 | fi
20 |
21 |
22 | BUILD_VERSION="$1";
23 | APPLE_UNAME="$2";
24 | APPLE_PWORD="$3";
25 |
26 |
27 | pushd /tmp/
28 | rm -rf workspace || true
29 | mkdir workspace
30 | cd workspace
31 | ln -s /Users/dannagle/github/cryptopp700 cryptopp700
32 | git clone https://github.com/dannagle/Cryptoknife
33 | cd Cryptoknife/src
34 | #git checkout development
35 |
36 | echo "Replacing globals.h with $BUILD_VERSION"
37 | sed -i '' '/BEGIN/,/END/c\
38 | #define SW_VERSION "v'$BUILD_VERSION'"
39 | ' globals.h
40 |
41 | echo "Replacing Info.plist with $BUILD_VERSION"
42 | sed -i '' 's/1.0<\/string>/'$BUILD_VERSION'<\/string>/' Info.plist
43 |
44 | "/Users/dannagle/Qt/5.12.0/clang_64/bin/qmake" Cryptoknife.pro -spec macx-clang CONFIG+=x86_64
45 | make
46 | /Users/dannagle/Qt/5.12.0/clang_64/bin/macdeployqt Cryptoknife.app -appstore-compliant
47 | codesign --option runtime --deep --force --sign "Developer ID Application: NagleCode, LLC (C77T3Q8VPT)" Cryptoknife.app
48 |
49 | rm -rf /Users/dannagle/github/cryptoknife/Cryptoknife.app || true
50 | mv Cryptoknife.app /Users/dannagle/github/Cryptoknife
51 |
52 | rm -rf newbuild.dmg || true
53 | "/Applications/DMG Canvas.app/Contents/Resources/dmgcanvas" "/Users/dannagle/github/cryptoknife/Cryptoknife.dmgCanvas" newbuild.dmg
54 |
55 | rm -rf /Users/dannagle/github/cryptoknife/Cryptoknife_v$BUILD_VERSION.dmg || true
56 | mv newbuild.dmg /Users/dannagle/github/cryptoknife/Cryptoknife_v$BUILD_VERSION.dmg
57 |
58 | echo "Finished creating Cryptoknife_v$BUILD_VERSION.dmg"
59 |
60 | echo "Sending to Apple for notary"
61 | xcrun altool --notarize-app -f /Users/dannagle/github/cryptoknife/Cryptoknife_v$BUILD_VERSION.dmg --primary-bundle-id 'com.cryptoknife.desktop' -u ''$APPLE_UNAME'' -p ''$APPLE_PWORD''
62 |
63 |
64 | popd
65 |
--------------------------------------------------------------------------------
/src/crypto.h:
--------------------------------------------------------------------------------
1 | #ifndef CRYPTO_H
2 | #define CRYPTO_H
3 |
4 | #include
5 |
6 |
7 | typedef unsigned char byte;
8 |
9 |
10 | class Crypto
11 | {
12 | public:
13 | Crypto();
14 |
15 | QString filename;
16 | QString result;
17 |
18 |
19 | bool doMD5;
20 | bool dosha1;
21 | bool dosha224;
22 | bool dosha256;
23 | bool dosha384;
24 | bool dosha512;
25 |
26 | bool domd4;
27 | bool domd2;
28 |
29 |
30 | bool doAESCBC;
31 | int aesBits;
32 | QString aesKey;
33 | QString aesIV;
34 |
35 | QString blowfishKey;
36 | QString blowfishIV;
37 |
38 | QString tripleDESKey;
39 | QString tripleDESIV;
40 |
41 | QString twofishKey;
42 | QString twofishIV;
43 |
44 | QString rc6Key;
45 | QString rc6IV;
46 |
47 | void doHash();
48 | void AES_CBC_Encrypt(const char *outfile);
49 | static void Base64Encode(const char *infile, const char *outfile);
50 | static void Base64Decode(const char *infile, const char *outfile);
51 | static void HEX2Bin(const char *infile, const char *outfile);
52 | static void Bin2HEX(const char *infile, const char *outfile);
53 | void AES_CBC_Decrypt(const char *outfile);
54 | static QString byteArrayToHex(QByteArray data);
55 |
56 |
57 | void Blowfish_CBC_Encrypt(const char *outfile);
58 | void Blowfish_CBC_Decrypt(const char *outfile);
59 |
60 | void hexString2Bytes (QString keyString, byte * resultKey, int keylength);
61 |
62 |
63 | void TripleDES2_CBC_Encrypt(const char *outfile);
64 | void TripleDES2_CBC_Decrypt(const char *outfile);
65 | static QString bytes2HexString(byte *resultKey, int keylength);
66 | void TripleDES3_CBC_Decrypt(const char *outfile);
67 | void TripleDES3_CBC_Encrypt(const char *outfile);
68 | void Twofish_CBC_Decrypt(const char *outfile);
69 | void Twofish_CBC_Encrypt(const char *outfile);
70 | void RC6_Decrypt(const char *outfile);
71 | void RC6_Encrypt(const char *outfile);
72 | static QByteArray HEXtoByteArray(QString thehex);
73 | static void GenerateKeys(QHash &keys, QHash &IVs);
74 | static quint64 Checksum(QString infile);
75 | };
76 |
77 | #endif // CRYPTO_H
78 |
--------------------------------------------------------------------------------
/src/mainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWINDOW_H
2 | #define MAINWINDOW_H
3 |
4 | #include
5 | #include
6 |
7 | namespace Ui {
8 | class MainWindow;
9 | }
10 |
11 | class MainWindow : public QMainWindow
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | explicit MainWindow(QWidget *parent = 0);
17 | ~MainWindow();
18 |
19 | void processSettings(bool save);
20 | public slots:
21 | void poodlepic();
22 | protected:
23 | void dragEnterEvent(QDragEnterEvent* event);
24 | void dragMoveEvent(QDragMoveEvent* event);
25 | void dragLeaveEvent(QDragLeaveEvent* event);
26 | void dropEvent(QDropEvent* event);
27 |
28 |
29 | virtual bool openFiles(const QStringList& pathList);
30 |
31 | private slots:
32 | void on_epochEdit_textEdited(const QString &arg1);
33 |
34 |
35 | void on_dateTimeEdit_dateTimeChanged(const QDateTime &dateTime);
36 |
37 |
38 | void on_asciiEdit_textChanged(const QString &arg1);
39 |
40 | void on_hexEdit_textEdited(const QString &arg1);
41 |
42 |
43 | void on_cancelButton_clicked();
44 |
45 |
46 | void on_deriveButton_clicked();
47 |
48 | void on_clearLogButton_clicked();
49 |
50 | void on_toClipBoardButton_clicked();
51 |
52 | void on_hashCalcButton_clicked();
53 |
54 | void on_encodeCalcButton_clicked();
55 |
56 | QString systemProfile();
57 |
58 | void on_systemProfileButton_clicked();
59 |
60 | void on_genSecurePWButton_clicked();
61 |
62 | void on_copyPWButton_clicked();
63 |
64 | void on_secureLengthCombo_currentIndexChanged(int index);
65 |
66 | void on_secureCapsCheck_toggled(bool checked);
67 |
68 | void on_secureSpecialCheck_toggled(bool checked);
69 |
70 | void on_secureNumsCheck_toggled(bool checked);
71 |
72 |
73 |
74 | void on_aesBitsCombo_currentIndexChanged(const QString &arg1);
75 |
76 | void on_tripleDESVariantCombo_currentIndexChanged(const QString &arg1);
77 |
78 | void on_deleteFileButton_clicked();
79 |
80 | private:
81 | Ui::MainWindow *ui;
82 | QString doCrypto(QString filename);
83 | void appendResult(QString result);
84 | bool epochedit;
85 | bool asciiedit;
86 |
87 | bool passwordedit;
88 | bool directHash;
89 |
90 | void launchBrowser();
91 |
92 | void generateUrlButton(QString name, QString link);
93 |
94 | bool cancel;
95 | QStringList magicNumbersToFile(QByteArray initialbytes);
96 | void logbuttondisplay();
97 | };
98 |
99 | #endif // MAINWINDOW_H
100 |
--------------------------------------------------------------------------------
/src/crc32.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | The MIT License (MIT)
3 |
4 | Copyright (c) Alexander Nusov 2015
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 |
25 | #include "crc32.h"
26 |
27 | #include
28 |
29 | Crc32::Crc32()
30 | {
31 | quint32 crc;
32 |
33 | // initialize CRC table
34 | for (int i = 0; i < 256; i++)
35 | {
36 | crc = i;
37 | for (int j = 0; j < 8; j++)
38 | crc = crc & 1 ? (crc >> 1) ^ 0xEDB88320UL : crc >> 1;
39 |
40 | crc_table[i] = crc;
41 | }
42 | }
43 |
44 | quint32 Crc32::calculateFromFile(QString filename)
45 | {
46 | quint32 crc;
47 | QFile file;
48 |
49 | char buffer[16000];
50 | int len, i;
51 |
52 | crc = 0xFFFFFFFFUL;
53 |
54 | file.setFileName(filename);
55 | if (file.open(QIODevice::ReadOnly))
56 | {
57 | while (!file.atEnd())
58 | {
59 | len = file.read(buffer, 16000);
60 | for (i = 0; i < len; i++)
61 | crc = crc_table[(crc ^ buffer[i]) & 0xFF] ^ (crc >> 8);
62 | }
63 |
64 | file.close();
65 | }
66 |
67 | return crc ^ 0xFFFFFFFFUL;
68 | }
69 |
70 | void Crc32::initInstance(int i)
71 | {
72 | instances[i] = 0xFFFFFFFFUL;
73 | }
74 |
75 | void Crc32::pushData(int i, char *data, int len)
76 | {
77 | quint32 crc = instances[i];
78 | if (crc)
79 | {
80 | for (int j = 0; j < len; j++)
81 | crc = crc_table[(crc ^ data[j]) & 0xFF] ^ (crc >> 8);
82 |
83 | instances[i] = crc;
84 | }
85 | }
86 |
87 | quint32 Crc32::releaseInstance(int i)
88 | {
89 | quint32 crc32 = instances[i];
90 | if (crc32) {
91 | instances.remove(i);
92 | return crc32 ^ 0xFFFFFFFFUL;
93 | }
94 | else {
95 | return 0;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cryptoknife
2 |   
3 |
4 | Cryptoknife is an open source portable utility to allow hashing, encoding, and encryption through a simple drag-and-drop interface. It also comes with a collection of miscellaneous tools. The mainline branch officially supports Windows and Mac. Cryptoknife is free and licensed GPL v2 or later. It can be used for both commercial and personal use.
5 |
6 |
7 | Cryptoknife works by checking boxes for the calculations and then dragging files to run the calculation. Cryptoknife performs the work from every checked box on *every tab* and displays the output the log and saves to a log file. By default, very common hashing boxes are pre-checked.
8 |
9 |
10 |
11 |
12 | ## Support
13 |
14 | * Twitter: [@NagleCode](http://twitter.com/naglecode)
15 | * You may also track this project on [GitHub](http://github.com/dannagle/Cryptoknife).
16 | * Secure Anonymous Email: [Contact me](https://cryptoknife.com/contact)
17 |
18 | ## Settings and Log
19 | for Windows, the settings are saved as `cryptoknife_settings.ini` inside the run-time directory. The log file is `cryptoknife.log` is also in the run-time directory.
20 |
21 | For Mac, settings are saved in `Library/Application Support/com.cryptoknife/cryptoknife_settings.ini`. The log file is `cryptoknife.log` and is saved in your `Downloads` directory.
22 |
23 | Settings are saved when the app exits. The log is saved whenever the console is updated.
24 |
25 |
26 | ### Hashing
27 | Simply check the boxes for the algorithms to use, and then drag-and-drop your directory or file.
28 |
29 | 
30 |
31 | * MD5, MD4, MD2
32 | * SHA-1, 224, 256, 384, 256
33 | * CRC-32
34 | * Checksum
35 |
36 | There is also direct input available. Cryptoknife will perform all hashing algorithms on direct input.
37 |
38 | ### Encoding
39 | Except for line-ending conversion, Cryptoknife appends a new file extension when performing its work. However, it is still very easy to drag-and-drop and encoder/encrypt thousands of files. With great power comes great responsibility.
40 |
41 | 
42 |
43 |
44 | * Base64
45 | * HEX/Binary
46 | * DOS/Unix EOL
47 |
48 | There is also direct input available. Results are displayed (which may not be viewable for binary results).
49 |
50 |
51 | ### Encryption
52 | All the encryption algorithms use CBC mode. You may supply your own Key/IV or generate a new one. Note that if you change the bit-level, you need to re-click "Generate" since different bits require different lengths.
53 |
54 | 
55 |
56 | * AES/Rijndael CBC
57 | * Blowfish CBC
58 | * Triple DES CBC
59 | * Twofish CBC
60 |
61 | ### Utilities
62 | System profile gives a listing of RAM, processor, attached drives, and IP addresses. It is also ran on start-up. ASCII/HEX is the same conversion interface used by Packet Sender. Epoch/Date is a very common calculation used in development. Password Generator has various knobs to create a secure password.
63 |
64 | 
65 |
66 | * System Profile
67 | * ASCII/HEX
68 | * Epoch/Date convert
69 | * Password Generator
70 |
71 | Using Cryptoknife, an open-source utility which generates no network traffic, is a very safe way to generate a password.
72 |
73 | ### Building
74 | Cryptoknife uses these libraries.
75 | * https://www.cryptopp.com/
76 | * https://www.qt.io/download-open-source/
77 |
78 | All the project files are statically-linked to create a single executable in Windows. Mac uses dynamic linking since apps are just directories.
79 |
80 | ## Sponsorships
81 | Would you like your name or brand listed on this website? Please contact me for sponsorship opportunities.
82 |
83 | ## License
84 | GPL v2 or Later. [Contact me](https://cryptoknife.com/contact) if you require a different license.
85 |
86 |
87 | ## Copyright
88 |
89 | Cryptoknife is wholly owned and copyright © - [@NagleCode](http://twitter.com/NagleCode) - [DanNagle.com](http://DanNagle.com) - [Cryptoknife.com](https://cryptoknife.com)
90 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 | *.vcxproj.filters
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015 cache/options directory
29 | .vs/
30 | # Uncomment if you have tasks that create the project's static files in wwwroot
31 | #wwwroot/
32 |
33 | # MSTest test Results
34 | [Tt]est[Rr]esult*/
35 | [Bb]uild[Ll]og.*
36 |
37 | # NUNIT
38 | *.VisualState.xml
39 | TestResult.xml
40 |
41 | # Build Results of an ATL Project
42 | [Dd]ebugPS/
43 | [Rr]eleasePS/
44 | dlldata.c
45 |
46 | # .NET Core
47 | project.lock.json
48 | project.fragment.lock.json
49 | artifacts/
50 | **/Properties/launchSettings.json
51 |
52 | *_i.c
53 | *_p.c
54 | *_i.h
55 | *.ilk
56 | *.meta
57 | *.obj
58 | *.pch
59 | *.pdb
60 | *.pgc
61 | *.pgd
62 | *.rsp
63 | *.sbr
64 | *.tlb
65 | *.tli
66 | *.tlh
67 | *.tmp
68 | *.tmp_proj
69 | *.log
70 | *.vspscc
71 | *.vssscc
72 | .builds
73 | *.pidb
74 | *.svclog
75 | *.scc
76 |
77 | # Chutzpah Test files
78 | _Chutzpah*
79 |
80 | # Visual C++ cache files
81 | ipch/
82 | *.aps
83 | *.ncb
84 | *.opendb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 | *.VC.db
89 | *.VC.VC.opendb
90 |
91 | # Visual Studio profiler
92 | *.psess
93 | *.vsp
94 | *.vspx
95 | *.sap
96 |
97 | # TFS 2012 Local Workspace
98 | $tf/
99 |
100 | # Guidance Automation Toolkit
101 | *.gpState
102 |
103 | # ReSharper is a .NET coding add-in
104 | _ReSharper*/
105 | *.[Rr]e[Ss]harper
106 | *.DotSettings.user
107 |
108 | # JustCode is a .NET coding add-in
109 | .JustCode
110 |
111 | # TeamCity is a build add-in
112 | _TeamCity*
113 |
114 | # DotCover is a Code Coverage Tool
115 | *.dotCover
116 |
117 | # Visual Studio code coverage results
118 | *.coverage
119 | *.coveragexml
120 |
121 | # NCrunch
122 | _NCrunch_*
123 | .*crunch*.local.xml
124 | nCrunchTemp_*
125 |
126 | # MightyMoose
127 | *.mm.*
128 | AutoTest.Net/
129 |
130 | # Web workbench (sass)
131 | .sass-cache/
132 |
133 | # Installshield output folder
134 | [Ee]xpress/
135 |
136 | # DocProject is a documentation generator add-in
137 | DocProject/buildhelp/
138 | DocProject/Help/*.HxT
139 | DocProject/Help/*.HxC
140 | DocProject/Help/*.hhc
141 | DocProject/Help/*.hhk
142 | DocProject/Help/*.hhp
143 | DocProject/Help/Html2
144 | DocProject/Help/html
145 |
146 | # Click-Once directory
147 | publish/
148 |
149 | # Publish Web Output
150 | *.[Pp]ublish.xml
151 | *.azurePubxml
152 | # TODO: Comment the next line if you want to checkin your web deploy settings
153 | # but database connection strings (with potential passwords) will be unencrypted
154 | *.pubxml
155 | *.publishproj
156 |
157 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
158 | # checkin your Azure Web App publish settings, but sensitive information contained
159 | # in these scripts will be unencrypted
160 | PublishScripts/
161 |
162 | # NuGet Packages
163 | *.nupkg
164 | # The packages folder can be ignored because of Package Restore
165 | **/packages/*
166 | # except build/, which is used as an MSBuild target.
167 | !**/packages/build/
168 | # Uncomment if necessary however generally it will be regenerated when needed
169 | #!**/packages/repositories.config
170 | # NuGet v3's project.json files produces more ignoreable files
171 | *.nuget.props
172 | *.nuget.targets
173 |
174 | # Microsoft Azure Build Output
175 | csx/
176 | *.build.csdef
177 |
178 | # Microsoft Azure Emulator
179 | ecf/
180 | rcf/
181 |
182 | # Windows Store app package directories and files
183 | AppPackages/
184 | BundleArtifacts/
185 | Package.StoreAssociation.xml
186 | _pkginfo.txt
187 |
188 | # Visual Studio cache files
189 | # files ending in .cache can be ignored
190 | *.[Cc]ache
191 | # but keep track of directories ending in .cache
192 | !*.[Cc]ache/
193 |
194 | # Others
195 | ClientBin/
196 | ~$*
197 | *~
198 | *.dbmdl
199 | *.dbproj.schemaview
200 | *.jfm
201 | *.pfx
202 | *.publishsettings
203 | node_modules/
204 | orleans.codegen.cs
205 |
206 | # Since there are multiple workflows, uncomment next line to ignore bower_components
207 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
208 | #bower_components/
209 |
210 | # RIA/Silverlight projects
211 | Generated_Code/
212 |
213 | # Backup & report files from converting an old project file
214 | # to a newer Visual Studio version. Backup files are not needed,
215 | # because we have git ;-)
216 | _UpgradeReport_Files/
217 | Backup*/
218 | UpgradeLog*.XML
219 | UpgradeLog*.htm
220 |
221 | # SQL Server files
222 | *.mdf
223 | *.ldf
224 |
225 | # Business Intelligence projects
226 | *.rdl.data
227 | *.bim.layout
228 | *.bim_*.settings
229 |
230 | # Microsoft Fakes
231 | FakesAssemblies/
232 |
233 | # GhostDoc plugin setting file
234 | *.GhostDoc.xml
235 |
236 | # Node.js Tools for Visual Studio
237 | .ntvs_analysis.dat
238 |
239 | # Visual Studio 6 build log
240 | *.plg
241 |
242 | # Visual Studio 6 workspace options file
243 | *.opt
244 |
245 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
246 | *.vbw
247 |
248 | # Visual Studio LightSwitch build output
249 | **/*.HTMLClient/GeneratedArtifacts
250 | **/*.DesktopClient/GeneratedArtifacts
251 | **/*.DesktopClient/ModelManifest.xml
252 | **/*.Server/GeneratedArtifacts
253 | **/*.Server/ModelManifest.xml
254 | _Pvt_Extensions
255 |
256 | # Paket dependency manager
257 | .paket/paket.exe
258 | paket-files/
259 |
260 | # FAKE - F# Make
261 | .fake/
262 |
263 | # JetBrains Rider
264 | .idea/
265 | *.sln.iml
266 |
267 | # CodeRush
268 | .cr/
269 |
270 | # Python Tools for Visual Studio (PTVS)
271 | __pycache__/
272 | *.pyc
273 |
274 | # Cake - Uncomment if you are using it
275 | # tools/
276 | # Xcode
277 | #
278 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
279 |
280 | ## Build generated
281 | build/
282 | DerivedData/
283 |
284 | ## Various settings
285 | *.pbxuser
286 | !default.pbxuser
287 | *.mode1v3
288 | !default.mode1v3
289 | *.mode2v3
290 | !default.mode2v3
291 | *.perspectivev3
292 | !default.perspectivev3
293 | xcuserdata/
294 |
295 | ## Other
296 | *.moved-aside
297 | *.xccheckout
298 | *.xcscmblueprint
299 | *.DS_Store
300 | .AppleDouble
301 | .LSOverride
302 |
303 | # Icon must end with two \r
304 | Icon
305 |
306 |
307 | # Thumbnails
308 | ._*
309 |
310 | # Files that might appear in the root of a volume
311 | .DocumentRevisions-V100
312 | .fseventsd
313 | .Spotlight-V100
314 | .TemporaryItems
315 | .Trashes
316 | .VolumeIcon.icns
317 | .com.apple.timemachine.donotpresent
318 |
319 | # Directories potentially created on remote AFP share
320 | .AppleDB
321 | .AppleDesktop
322 | Network Trash Folder
323 | Temporary Items
324 | .apdisk
325 | # Windows thumbnail cache files
326 | Thumbs.db
327 | ehthumbs.db
328 | ehthumbs_vista.db
329 |
330 | # Folder config file
331 | Desktop.ini
332 |
333 | # Recycle Bin used on file shares
334 | $RECYCLE.BIN/
335 |
336 | # Windows Installer files
337 | *.cab
338 | *.msi
339 | *.msm
340 | *.msp
341 |
342 | # Windows shortcuts
343 | *.lnk
344 |
345 |
346 | # C++ objects and libs
347 |
348 | *.slo
349 | *.lo
350 | *.o
351 | *.a
352 | *.la
353 | *.lai
354 | *.so
355 | *.dll
356 | *.dylib
357 |
358 | # Qt-es
359 |
360 | /.qmake.cache
361 | /.qmake.stash
362 | *.pro.user
363 | *.pro.user.*
364 | *.qbs.user
365 | *.qbs.user.*
366 | *.moc
367 | moc_*.cpp
368 | qrc_*.cpp
369 | ui_*.h
370 | Makefile*
371 | *build-*
372 |
373 | # QtCreator
374 |
375 | *.autosave
376 |
377 | # QtCtreator Qml
378 | *.qmlproject.user
379 | *.qmlproject.user.*
380 |
381 | # QtCtreator CMake
382 | CMakeLists.txt.user*
383 |
384 |
385 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/src/crypto.cpp:
--------------------------------------------------------------------------------
1 | #include "crypto.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 |
11 | #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
12 |
13 | #include
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 |
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 |
49 |
50 | #include
51 | #include
52 | #include
53 |
54 | #include
55 |
56 |
57 | USING_NAMESPACE(CryptoPP)
58 | USING_NAMESPACE(std)
59 |
60 | #include "globals.h"
61 |
62 | /*
63 |
64 | Should remove key/iv altogether and rely on PKCS5_PBKDF2_HMAC to derive...
65 | http://stackoverflow.com/questions/23349266/is-this-encryption-method-secure
66 |
67 |
68 | CryptoPP::AutoSeededRandomPool rnd;
69 | rnd.GenerateBlock(iv, CryptoPP::AES::BLOCKSIZE);
70 | rnd.GenerateBlock(salt, SALT_SIZE);
71 |
72 | CryptoPP::PKCS5_PBKDF2_HMAC gen;
73 | gen.DeriveKey(key, CryptoPP::AES::MAX_KEYLENGTH, 32,
74 | password, pswd.length(),
75 | salt, SALT_SIZE,
76 | 256);
77 | */
78 | void Crypto::GenerateKeys(QHash &keys, QHash &IVs)
79 | {
80 | QStringList ciphernames;
81 |
82 | ciphernames.clear();
83 |
84 | ciphernames <<"aes-128-cbc" << "aes-192-cbc" << "aes-256-cbc"
85 | <<"bf-cbc" << "des-ede3-cbc" << "des-ede-cbc"
86 | << "twofish" << "rc6";
87 |
88 |
89 | keys.clear();
90 | IVs.clear();
91 |
92 |
93 | QString ciphername;
94 |
95 | foreach (ciphername, ciphernames) {
96 | //do it
97 |
98 | int ivsize = CryptoPP::AES::BLOCKSIZE;
99 | int keylength = CryptoPP::AES::MAX_KEYLENGTH;
100 | int saltlength = 8; //what openssl uses
101 |
102 | if(ciphername == ("aes-128-cbc")) {
103 | keylength = CryptoPP::AES::DEFAULT_KEYLENGTH;
104 | }
105 |
106 | if(ciphername == ("aes-128-cbc")) {
107 | keylength = CryptoPP::AES::DEFAULT_KEYLENGTH;
108 | }
109 |
110 | if(ciphername.contains("bf")) {
111 | ivsize = CryptoPP::Blowfish::BLOCKSIZE;
112 | keylength = CryptoPP::Blowfish::MAX_KEYLENGTH;
113 | }
114 |
115 | if(ciphername == ("des-ede3-cbc")) {
116 | ivsize = CryptoPP::DES_EDE3::BLOCKSIZE;
117 | keylength = CryptoPP::DES_EDE3::DEFAULT_KEYLENGTH;
118 | }
119 |
120 | if(ciphername == ("des-ede-cbc")) {
121 | ivsize = CryptoPP::DES_EDE2::BLOCKSIZE;
122 | keylength = CryptoPP::DES_EDE2::DEFAULT_KEYLENGTH;
123 | }
124 |
125 | if(ciphername == ("twofish")) {
126 | ivsize = CryptoPP::Twofish::BLOCKSIZE;
127 | keylength = CryptoPP::Twofish::DEFAULT_KEYLENGTH;
128 | }
129 |
130 |
131 | byte iv[ivsize];
132 | byte key[keylength];
133 |
134 |
135 | CryptoPP::AutoSeededRandomPool rnd;
136 | rnd.GenerateBlock(key, keylength);
137 | rnd.GenerateBlock(iv, ivsize);
138 |
139 |
140 | /*
141 | *
142 | * openssl enc -aes-256-cbc -k password -nosalt -p < /dev/null
143 | key=5F4DCC3B5AA765D61D8327DEB882CF992B95990A9151374ABD8FF8C5A7A0FE08
144 | iv =B7B4372CDFBCB3D16A2631B59B509E94
145 | */
146 |
147 | QByteArray keyArray = QByteArray::fromRawData((const char *)key, keylength);
148 | QByteArray ivArray = QByteArray::fromRawData((const char *)iv, ivsize);
149 |
150 |
151 | QString keyString = QString(keyArray.toHex().toUpper());
152 | QString ivString = QString(ivArray.toHex().toUpper());
153 |
154 |
155 | QDEBUG() << ciphername << keyString << ivString ;
156 |
157 | keys[ciphername] = keyString;
158 | IVs[ciphername] = ivString;
159 | }
160 |
161 |
162 |
163 |
164 | }
165 |
166 |
167 | SecByteBlock HexDecodeString(const char *hex)
168 | {
169 | StringSource ss(hex, true, new HexDecoder);
170 | SecByteBlock result((size_t)ss.MaxRetrievable());
171 | ss.Get(result, result.size());
172 | return result;
173 | }
174 |
175 | void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char *infile, const char *outfile)
176 | {
177 | SecByteBlock key = HexDecodeString(hexKey);
178 | SecByteBlock iv = HexDecodeString(hexIV);
179 | CTR_Mode::Encryption aes(key, key.size(), iv);
180 | FileSource(infile, true, new StreamTransformationFilter(aes, new FileSink(outfile)));
181 | }
182 |
183 |
184 | void Crypto::AES_CBC_Decrypt(const char *outfile)
185 | {
186 |
187 | //AES can use 16, 24, or 32 byte keys (128, 192, and 256 bits respectively).
188 |
189 |
190 | QDEBUGVAR(aesKey);
191 | QDEBUGVAR(aesIV);
192 |
193 | if(aesBits < 16) {
194 | aesBits = 16;
195 | }
196 |
197 | int keylength = AES::DEFAULT_KEYLENGTH;
198 | if(aesBits == 128) {
199 | keylength = 16;
200 | }
201 | if(aesBits == 192) {
202 | keylength = 24;
203 | }
204 | if(aesBits == 256) {
205 | keylength = 32;
206 | }
207 |
208 | if(aesKey.size() < keylength) {
209 | QDEBUG() << "aesKey is wrong size" << aesKey.size() << "vs" << keylength;
210 | return;
211 | }
212 |
213 | if(aesIV.size() < AES::BLOCKSIZE) {
214 | QDEBUG() << "aesIV is wrong size" << aesIV.size() << "vs" << AES::BLOCKSIZE;
215 | return;
216 | }
217 |
218 | byte resultKey[keylength];
219 | byte resultIV[ AES::BLOCKSIZE] = {0};
220 | hexString2Bytes(aesKey, resultKey, keylength);
221 | hexString2Bytes(aesIV, resultIV, AES::BLOCKSIZE);
222 |
223 |
224 | QString tempString = bytes2HexString(resultKey, keylength);
225 |
226 | if(aesKey == tempString) {
227 | QDEBUG() << "Re-encoding is good";
228 | } else {
229 | QDEBUG() << aesKey << "vs" << tempString;
230 | }
231 |
232 |
233 |
234 | auto d = CBC_Mode::Decryption(resultKey, keylength, resultIV);
235 |
236 | try
237 | {
238 |
239 |
240 | // The StreamTransformationFilter removes
241 | // padding as required.
242 | FileSource s(filename.toStdString().c_str(), true,
243 | new StreamTransformationFilter(d,
244 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
245 | ) // StreamTransformationFilter
246 | ); // StringSource
247 |
248 | }
249 | catch(const CryptoPP::Exception& e)
250 | {
251 | QDEBUG() << QString(e.what());
252 | }
253 |
254 | }
255 |
256 |
257 | void Crypto::TripleDES3_CBC_Encrypt(const char *outfile)
258 | {
259 |
260 | byte iv[DES_EDE3::BLOCKSIZE];
261 | byte key[DES_EDE3::DEFAULT_KEYLENGTH];
262 |
263 | int keylength = DES_EDE3::DEFAULT_KEYLENGTH;
264 |
265 | hexString2Bytes(tripleDESKey, key, keylength);
266 | hexString2Bytes(tripleDESIV, iv, DES_EDE3::BLOCKSIZE);
267 | tripleDESKey = bytes2HexString(key, sizeof(key));
268 | tripleDESIV = bytes2HexString(iv, sizeof(iv));
269 |
270 |
271 | try
272 | {
273 |
274 | CBC_Mode< DES_EDE3 >::Encryption e;
275 | e.SetKeyWithIV(key, sizeof(key), iv);
276 |
277 |
278 | // The StreamTransformationFilter removes
279 | // padding as required.
280 | FileSource s(filename.toStdString().c_str(), true,
281 | new StreamTransformationFilter(e,
282 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
283 | ) // StreamTransformationFilter
284 | ); // StringSource
285 |
286 | /*
287 | QString immediatetest = filename + ".immediatetest";
288 |
289 |
290 | auto d = CBC_Mode::Decryption(key, sizeof(key), iv);
291 |
292 | // The StreamTransformationFilter removes
293 | // padding as required.
294 | FileSource s2(outfile, true,
295 | new StreamTransformationFilter(d,
296 | new FileSink(immediatetest.toStdString().c_str()), StreamTransformationFilter::PKCS_PADDING
297 | ) // StreamTransformationFilter
298 | ); // StringSource
299 | */
300 | QDEBUG() << "The openssl command is...";
301 |
302 | QString outcommand; outcommand.clear();
303 | QTextStream out (& outcommand);
304 | out << "openssl des-ede3-cbc -d -K " << tripleDESKey << " -iv " << tripleDESIV <<
305 | " -in " << QString(outfile) << " -out " << filename;
306 |
307 | QDEBUG() << "The openssl command is...";
308 | QDEBUG() << outcommand;
309 |
310 | }
311 | catch(const CryptoPP::Exception& e)
312 | {
313 | cerr << e.what() << endl;
314 | exit(1);
315 | }
316 |
317 | //OpenSSL command looks like openssl
318 | //blowfish-128-cbc -d -K 41517050DF93EE6FCA8BA4DAC2B1DB17 -iv D39E88E886EDBF6D4F6E73ED4D18D443 -in testfile.txt.enc -out testfile.txt.enc.openssl.txt
319 |
320 | QDEBUG() << "outfile text: " << outfile << endl;
321 |
322 |
323 |
324 | }
325 |
326 | void Crypto::Twofish_CBC_Decrypt(const char *outfile)
327 | {
328 |
329 | }
330 |
331 | void Crypto::Twofish_CBC_Encrypt(const char *outfile)
332 | {
333 |
334 |
335 | byte iv[Twofish::BLOCKSIZE];
336 | byte key[Twofish::DEFAULT_KEYLENGTH];
337 |
338 | int keylength = Twofish::DEFAULT_KEYLENGTH;
339 |
340 | hexString2Bytes(twofishKey, key, keylength);
341 | hexString2Bytes(twofishIV, iv, DES_EDE2::BLOCKSIZE);
342 |
343 | twofishKey = bytes2HexString(key, sizeof(key));
344 | twofishIV = bytes2HexString(iv, sizeof(iv));
345 |
346 | try
347 | {
348 |
349 | CBC_Mode< Twofish >::Encryption e;
350 | e.SetKeyWithIV(key, sizeof(key), iv);
351 |
352 |
353 | // The StreamTransformationFilter removes
354 | // padding as required.
355 | FileSource s(filename.toStdString().c_str(), true,
356 | new StreamTransformationFilter(e,
357 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
358 | ) // StreamTransformationFilter
359 | ); // StringSource
360 |
361 | /*
362 | QString immediatetest = filename + ".immediatetest";
363 |
364 |
365 | auto d = CBC_Mode::Decryption(key, sizeof(key), iv);
366 |
367 | // The StreamTransformationFilter removes
368 | // padding as required.
369 | FileSource s2(outfile, true,
370 | new StreamTransformationFilter(d,
371 | new FileSink(immediatetest.toStdString().c_str()), StreamTransformationFilter::PKCS_PADDING
372 | ) // StreamTransformationFilter
373 | ); // StringSource
374 | */
375 | QDEBUG() << "The openssl command is does not exist for twofish";
376 |
377 |
378 | }
379 | catch(const CryptoPP::Exception& e)
380 | {
381 | cerr << e.what() << endl;
382 | exit(1);
383 | }
384 |
385 | //OpenSSL command looks like openssl
386 | //blowfish-128-cbc -d -K 41517050DF93EE6FCA8BA4DAC2B1DB17 -iv D39E88E886EDBF6D4F6E73ED4D18D443 -in testfile.txt.enc -out testfile.txt.enc.openssl.txt
387 |
388 | QDEBUG() << "outfile text: " << outfile << endl;
389 |
390 | }
391 |
392 | void Crypto::RC6_Decrypt(const char *outfile)
393 | {
394 |
395 | }
396 |
397 | void Crypto::RC6_Encrypt(const char *outfile)
398 | {
399 |
400 | }
401 |
402 | void Crypto::TripleDES2_CBC_Encrypt(const char *outfile)
403 | {
404 |
405 | byte iv[DES_EDE2::BLOCKSIZE];
406 | byte key[DES_EDE2::DEFAULT_KEYLENGTH];
407 |
408 | int keylength = DES_EDE2::DEFAULT_KEYLENGTH;
409 |
410 | hexString2Bytes(tripleDESKey, key, keylength);
411 | hexString2Bytes(tripleDESIV, iv, DES_EDE2::BLOCKSIZE);
412 |
413 | tripleDESKey = bytes2HexString(key, sizeof(key));
414 | tripleDESIV = bytes2HexString(iv, sizeof(iv));
415 |
416 |
417 | try
418 | {
419 |
420 | CBC_Mode< DES_EDE2 >::Encryption e;
421 | e.SetKeyWithIV(key, sizeof(key), iv);
422 |
423 |
424 | // The StreamTransformationFilter removes
425 | // padding as required.
426 | FileSource s(filename.toStdString().c_str(), true,
427 | new StreamTransformationFilter(e,
428 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
429 | ) // StreamTransformationFilter
430 | ); // StringSource
431 |
432 | /*
433 | QString immediatetest = filename + ".immediatetest";
434 |
435 |
436 | auto d = CBC_Mode::Decryption(key, sizeof(key), iv);
437 |
438 | // The StreamTransformationFilter removes
439 | // padding as required.
440 | FileSource s2(outfile, true,
441 | new StreamTransformationFilter(d,
442 | new FileSink(immediatetest.toStdString().c_str()), StreamTransformationFilter::PKCS_PADDING
443 | ) // StreamTransformationFilter
444 | ); // StringSource
445 | */
446 | QDEBUG() << "The openssl command is...";
447 |
448 | QString outcommand; outcommand.clear();
449 | QTextStream out (& outcommand);
450 | out << "openssl des-ede-cbc -d -K " << tripleDESKey << " -iv " << tripleDESIV <<
451 | " -in " << QString(outfile) << " -out " << filename;
452 |
453 | QDEBUG() << "The openssl command is...";
454 | QDEBUG() << outcommand;
455 |
456 | }
457 | catch(const CryptoPP::Exception& e)
458 | {
459 | cerr << e.what() << endl;
460 | exit(1);
461 | }
462 |
463 | //OpenSSL command looks like openssl
464 | //blowfish-128-cbc -d -K 41517050DF93EE6FCA8BA4DAC2B1DB17 -iv D39E88E886EDBF6D4F6E73ED4D18D443 -in testfile.txt.enc -out testfile.txt.enc.openssl.txt
465 |
466 | QDEBUG() << "outfile text: " << outfile << endl;
467 |
468 |
469 |
470 |
471 | }
472 | void Crypto::TripleDES3_CBC_Decrypt(const char *outfile)
473 | {
474 | QDEBUGVAR(tripleDESKey);
475 | QDEBUGVAR(tripleDESIV);
476 |
477 |
478 | byte iv[DES_EDE3::BLOCKSIZE];
479 | byte key[DES_EDE3::DEFAULT_KEYLENGTH];
480 |
481 | int keylength = DES_EDE3::DEFAULT_KEYLENGTH;
482 |
483 |
484 | if(tripleDESKey.size() < keylength) {
485 | QDEBUG() << "tripleDESKey is wrong size" << tripleDESKey.size() << "vs" << keylength;
486 | return;
487 | }
488 |
489 | if(tripleDESIV.size() < DES_EDE3::DEFAULT_KEYLENGTH) {
490 | QDEBUG() << "tripleDESIV is wrong size" << tripleDESIV.size() << "vs" << Blowfish::BLOCKSIZE;
491 | return;
492 | }
493 |
494 | hexString2Bytes(tripleDESKey, key, keylength);
495 | hexString2Bytes(tripleDESIV, iv, DES_EDE3::BLOCKSIZE);
496 |
497 |
498 | QString tempString = bytes2HexString(key, keylength);
499 | if(tripleDESKey == tempString) {
500 | QDEBUG() << "Re-encoding is good";
501 | } else {
502 | QDEBUG() << tripleDESKey << "vs" << tempString;
503 | }
504 |
505 |
506 | auto d = CBC_Mode::Decryption(key, sizeof(key), iv);
507 | try
508 | {
509 |
510 |
511 | // The StreamTransformationFilter removes
512 | // padding as required.
513 | FileSource s(filename.toStdString().c_str(), true,
514 | new StreamTransformationFilter(d,
515 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
516 | ) // StreamTransformationFilter
517 | ); // StringSource
518 |
519 | }
520 | catch(const CryptoPP::Exception& e)
521 | {
522 | QDEBUG() << QString(e.what());
523 | }
524 |
525 |
526 | }
527 |
528 | void Crypto::TripleDES2_CBC_Decrypt(const char *outfile)
529 | {
530 | QDEBUGVAR(tripleDESKey);
531 | QDEBUGVAR(tripleDESIV);
532 |
533 |
534 | byte iv[DES_EDE2::BLOCKSIZE];
535 | byte key[DES_EDE2::DEFAULT_KEYLENGTH];
536 |
537 | int keylength = DES_EDE2::DEFAULT_KEYLENGTH;
538 |
539 |
540 | if(tripleDESKey.size() < keylength) {
541 | QDEBUG() << "tripleDESKey is wrong size" << tripleDESKey.size() << "vs" << keylength;
542 | return;
543 | }
544 |
545 | if(tripleDESIV.size() < DES_EDE2::DEFAULT_KEYLENGTH) {
546 | QDEBUG() << "tripleDESIV is wrong size" << tripleDESIV.size() << "vs" << Blowfish::BLOCKSIZE;
547 | return;
548 | }
549 |
550 | hexString2Bytes(tripleDESKey, key, keylength);
551 | hexString2Bytes(tripleDESIV, iv, DES_EDE2::BLOCKSIZE);
552 |
553 |
554 | QString tempString = bytes2HexString(key, keylength);
555 | if(tripleDESKey == tempString) {
556 | QDEBUG() << "Re-encoding is good";
557 | } else {
558 | QDEBUG() << tripleDESKey << "vs" << tempString;
559 | }
560 |
561 |
562 | auto d = CBC_Mode::Decryption(key, sizeof(key), iv);
563 | try
564 | {
565 |
566 |
567 | // The StreamTransformationFilter removes
568 | // padding as required.
569 | FileSource s(filename.toStdString().c_str(), true,
570 | new StreamTransformationFilter(d,
571 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
572 | ) // StreamTransformationFilter
573 | ); // StringSource
574 |
575 | }
576 | catch(const CryptoPP::Exception& e)
577 | {
578 | QDEBUG() << QString(e.what());
579 | }
580 |
581 |
582 | }
583 |
584 | void Crypto::AES_CBC_Encrypt(const char *outfile)
585 | {
586 |
587 | //AES can use 16, 24, or 32 byte keys (128, 192, and 256 bits respectively).
588 |
589 | if(aesBits < 16) {
590 | aesBits = 16;
591 | }
592 |
593 | int keylength = AES::DEFAULT_KEYLENGTH;
594 | if(aesBits == 128) {
595 | keylength = 16;
596 | }
597 | if(aesBits == 192) {
598 | keylength = 24;
599 | }
600 | if(aesBits == 256) {
601 | keylength = 32;
602 | }
603 |
604 |
605 |
606 | byte key[keylength];
607 | byte iv[AES::BLOCKSIZE];
608 |
609 |
610 | hexString2Bytes(aesKey, key, keylength);
611 | hexString2Bytes(aesIV, iv, AES::BLOCKSIZE);
612 |
613 | try
614 | {
615 |
616 | CBC_Mode< AES >::Encryption e;
617 | e.SetKeyWithIV(key, sizeof(key), iv);
618 |
619 |
620 | // The StreamTransformationFilter removes
621 | // padding as required.
622 | FileSource s(filename.toStdString().c_str(), true,
623 | new StreamTransformationFilter(e,
624 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
625 | ) // StreamTransformationFilter
626 | ); // StringSource
627 |
628 | /*
629 |
630 | QString immediatetest = filename + ".immediatetest";
631 |
632 |
633 | auto d = CBC_Mode::Decryption(key, sizeof(key), iv);
634 |
635 | // The StreamTransformationFilter removes
636 | // padding as required.
637 | FileSource s2(outfile, true,
638 | new StreamTransformationFilter(d,
639 | new FileSink(immediatetest.toStdString().c_str()), StreamTransformationFilter::PKCS_PADDING
640 | ) // StreamTransformationFilter
641 | ); // StringSource
642 | */
643 |
644 | QDEBUG() << "The openssl command is...";
645 |
646 | QString outcommand; outcommand.clear();
647 | QTextStream out (& outcommand);
648 | out << "openssl aes-" << aesBits << "-cbc -d -K " << aesKey << " -iv " << aesIV <<
649 | " -in " << QString(outfile) << " -out " << filename;
650 |
651 | QDEBUG() << "The openssl command is...";
652 | QDEBUG() << outcommand;
653 |
654 | }
655 | catch(const CryptoPP::Exception& e)
656 | {
657 | cerr << e.what() << endl;
658 | exit(1);
659 | }
660 |
661 | //OpenSSL command looks like openssl
662 | //aes-128-cbc -d -K 41517050DF93EE6FCA8BA4DAC2B1DB17 -iv D39E88E886EDBF6D4F6E73ED4D18D443 -in testfile.txt.enc -out testfile.txt.enc.openssl.txt
663 |
664 | QDEBUG() << "outfile text: " << outfile << endl;
665 | }
666 |
667 | void Crypto::Base64Encode(const char *infile, const char *outfile)
668 | {
669 | QFile filetest(infile);
670 | if(!filetest.exists()) return;
671 |
672 | FileSource(infile, true, new Base64Encoder(new FileSink(outfile), false));
673 | }
674 |
675 |
676 | quint64 Crypto::Checksum(QString infile)
677 | {
678 | QFile filetest(infile);
679 | if(!filetest.exists()) return 0;
680 | quint64 sum = 0;
681 | QByteArray data;
682 | quint64 mask = 0xFFFFFFFF;
683 | if(filetest.open(QFile::ReadOnly)) {
684 | while(!filetest.atEnd()) {
685 | data = filetest.read(1000*1000*10); // 10 megs at a time.
686 | QDEBUGVAR(data.size());
687 | for(int i = 0; i < data.size(); i++) {
688 | sum += ((unsigned int) data.at(i)) & 0xFF;
689 | }
690 | }
691 |
692 | filetest.close();
693 |
694 | }
695 |
696 | return (sum & mask);
697 |
698 |
699 |
700 | }
701 |
702 |
703 | void Crypto::Base64Decode(const char *infile, const char *outfile)
704 | {
705 | QFile filetest(infile);
706 | if(!filetest.exists()) return;
707 |
708 | FileSource(infile, true, new Base64Decoder(new FileSink(outfile)));
709 | }
710 |
711 | void Crypto::HEX2Bin(const char *infile, const char *outfile)
712 | {
713 | QFile filetest(infile);
714 | if(!filetest.exists()) return;
715 |
716 | FileSource(infile, true, new HexDecoder(new FileSink(outfile)));
717 | }
718 |
719 | void Crypto::Bin2HEX(const char *infile, const char *outfile)
720 | {
721 | QFile filetest(infile);
722 | if(!filetest.exists()) return;
723 |
724 | FileSource(infile, true, new HexEncoder(new FileSink(outfile)));
725 | }
726 |
727 |
728 | QString Crypto::byteArrayToHex(QByteArray data)
729 | {
730 | QString byte, returnString;
731 | // QDEBUG() << "size is " <::Encryption e;
789 | e.SetKeyWithIV(key, sizeof(key), iv);
790 |
791 |
792 | // The StreamTransformationFilter removes
793 | // padding as required.
794 | FileSource s(filename.toStdString().c_str(), true,
795 | new StreamTransformationFilter(e,
796 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
797 | ) // StreamTransformationFilter
798 | ); // StringSource
799 |
800 | /*
801 | QString immediatetest = filename + ".immediatetest";
802 |
803 |
804 | auto d = CBC_Mode::Decryption(key, sizeof(key), iv);
805 |
806 | // The StreamTransformationFilter removes
807 | // padding as required.
808 | FileSource s2(outfile, true,
809 | new StreamTransformationFilter(d,
810 | new FileSink(immediatetest.toStdString().c_str()), StreamTransformationFilter::PKCS_PADDING
811 | ) // StreamTransformationFilter
812 | ); // StringSource
813 | */
814 | QDEBUG() << "The openssl command is...";
815 |
816 | QString outcommand; outcommand.clear();
817 | QTextStream out (& outcommand);
818 | out << "openssl bf-cbc -d -K " << blowfishKey << " -iv " << blowfishIV <<
819 | " -in " << QString(outfile) << " -out " << filename;
820 |
821 | QDEBUG() << "The openssl command is...";
822 | QDEBUG() << outcommand;
823 |
824 | }
825 | catch(const CryptoPP::Exception& e)
826 | {
827 | cerr << e.what() << endl;
828 | exit(1);
829 | }
830 |
831 | //OpenSSL command looks like openssl
832 | //blowfish-128-cbc -d -K 41517050DF93EE6FCA8BA4DAC2B1DB17 -iv D39E88E886EDBF6D4F6E73ED4D18D443 -in testfile.txt.enc -out testfile.txt.enc.openssl.txt
833 |
834 | QDEBUG() << "outfile text: " << outfile << endl;
835 |
836 |
837 | }
838 |
839 | void Crypto::Blowfish_CBC_Decrypt(const char *outfile)
840 | {
841 |
842 |
843 | QDEBUGVAR(blowfishKey);
844 | QDEBUGVAR(blowfishIV);
845 |
846 | int keylength = Blowfish::DEFAULT_KEYLENGTH;
847 |
848 | if(blowfishKey.size() < keylength) {
849 | QDEBUG() << "blowfishKey is wrong size" << blowfishKey.size() << "vs" << keylength;
850 | return;
851 | }
852 |
853 | if(blowfishIV.size() < Blowfish::BLOCKSIZE) {
854 | QDEBUG() << "blowfishIV is wrong size" << blowfishIV.size() << "vs" << Blowfish::BLOCKSIZE;
855 | return;
856 | }
857 |
858 |
859 | byte resultKey[keylength];
860 | byte resultIV[ Blowfish::BLOCKSIZE] = {0};
861 | hexString2Bytes(blowfishKey, resultKey, keylength);
862 | hexString2Bytes(blowfishIV, resultIV, Blowfish::BLOCKSIZE);
863 |
864 |
865 | QString tempString = bytes2HexString(resultKey, keylength);
866 | if(blowfishKey == tempString) {
867 | QDEBUG() << "Re-encoding is good";
868 | } else {
869 | QDEBUG() << blowfishKey << "vs" << tempString;
870 | }
871 |
872 |
873 |
874 |
875 | auto d = CBC_Mode::Decryption(resultKey, keylength, resultIV);
876 |
877 | try
878 | {
879 |
880 |
881 | // The StreamTransformationFilter removes
882 | // padding as required.
883 | FileSource s(filename.toStdString().c_str(), true,
884 | new StreamTransformationFilter(d,
885 | new FileSink(outfile), StreamTransformationFilter::PKCS_PADDING
886 | ) // StreamTransformationFilter
887 | ); // StringSource
888 |
889 | }
890 | catch(const CryptoPP::Exception& e)
891 | {
892 | QDEBUG() << QString(e.what());
893 | }
894 |
895 |
896 | }
897 |
898 |
899 | QString Crypto::bytes2HexString(byte *resultKey, int keylength)
900 | {
901 | string tempString;
902 |
903 | //reverse it.
904 | StringSource(resultKey, keylength, true,
905 | new HexEncoder(
906 | new StringSink(tempString)
907 | ) // HexEncoder
908 | ); // StringSource
909 |
910 | return QString(tempString.c_str());
911 |
912 | }
913 |
914 |
915 | QByteArray Crypto::HEXtoByteArray(QString thehex)
916 | {
917 | thehex = thehex.trimmed();
918 | QString byte;
919 | QByteArray returnArray;
920 | QStringList hexSplit = thehex.simplified().split(" ");
921 | returnArray.clear();
922 | unsigned int foundByte = 0;
923 | bool ok = false;
924 |
925 | if(hexSplit.size() == 1) {
926 | //big fat hex stream.
927 | if((thehex.size() > 2) && ((thehex.size() % 2) == 0)) {
928 | hexSplit.clear();
929 | for(int two = 0; two < thehex.size(); two +=2) {
930 | QString append = QString(thehex[two]);
931 | append.append(QString(thehex[two+1]));
932 | hexSplit << append;
933 | }
934 | }
935 | }
936 |
937 |
938 | foreach(byte, hexSplit)
939 | {
940 | foundByte = byte.toUInt(&ok, 16);
941 | foundByte = foundByte & 0xff;
942 | if(ok)
943 | {
944 | returnArray.append(foundByte);
945 | }
946 |
947 | }
948 |
949 | return returnArray;
950 |
951 | }
952 |
953 | void Crypto::hexString2Bytes(QString keyString, byte *resultKey, int keylength)
954 | {
955 |
956 | QByteArray byteData = HEXtoByteArray(keyString);
957 | memset(resultKey, 0, keylength);
958 | for(int i=0; i
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 1074
10 | 658
11 |
12 |
13 |
14 |
15 | 0
16 | 0
17 |
18 |
19 |
20 | MainWindow
21 |
22 |
23 |
24 | -
25 |
26 |
-
27 |
28 |
29 |
30 | 0
31 | 0
32 |
33 |
34 |
35 | QTabWidget::North
36 |
37 |
38 | QTabWidget::Triangular
39 |
40 |
41 | 1
42 |
43 |
44 |
45 | Hashing
46 |
47 |
48 |
-
49 |
50 |
51 | MD5
52 |
53 |
54 |
55 | -
56 |
57 |
58 | SHA-1
59 |
60 |
61 |
62 | -
63 |
64 |
65 | SHA-224
66 |
67 |
68 |
69 | -
70 |
71 |
72 | SHA-256
73 |
74 |
75 |
76 | -
77 |
78 |
79 | SHA-384
80 |
81 |
82 |
83 | -
84 |
85 |
86 | SHA-512
87 |
88 |
89 |
90 | -
91 |
92 |
93 | MD4
94 |
95 |
96 |
97 | -
98 |
99 |
100 | MD2
101 |
102 |
103 |
104 | -
105 |
106 |
107 | CRC-32
108 |
109 |
110 |
111 | -
112 |
113 |
-
114 |
115 |
116 | 8-Bit Checksum (32 bit result)
117 |
118 |
119 |
120 |
121 |
122 | -
123 |
124 |
-
125 |
126 |
-
127 |
128 |
129 | Direct Input
130 |
131 |
132 |
133 | -
134 |
135 |
136 | Calculate
137 |
138 |
139 |
140 |
141 |
142 | -
143 |
144 |
145 |
146 | 0
147 | 0
148 |
149 |
150 |
151 | false
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | Encoding
162 |
163 |
164 | -
165 |
166 |
167 |
168 |
169 |
170 |
-
171 |
172 |
173 | File Translation
174 |
175 |
176 |
177 | -
178 |
179 |
180 | New File Extension
181 |
182 |
183 |
184 | -
185 |
186 |
187 | Base64 Encode
188 |
189 |
190 |
191 | -
192 |
193 |
194 | .base64.txt
195 |
196 |
197 |
198 | -
199 |
200 |
201 | Base 64 Decode
202 |
203 |
204 |
205 | -
206 |
207 |
208 | .bin
209 |
210 |
211 |
212 | -
213 |
214 |
215 | Binary to Hex
216 |
217 |
218 |
219 | -
220 |
221 |
222 | .hex.txt
223 |
224 |
225 |
226 | -
227 |
228 |
229 | Hex to Binary
230 |
231 |
232 |
233 | -
234 |
235 |
236 | .bin
237 |
238 |
239 |
240 |
241 |
242 |
243 | -
244 |
245 |
246 |
247 | 0
248 | 0
249 |
250 |
251 |
252 | Line Endings Conversion (Overwrites file)
253 |
254 |
255 |
-
256 |
257 |
258 | Enabled
259 |
260 |
261 |
262 | -
263 |
264 |
265 | Qt::Horizontal
266 |
267 |
268 |
269 | 86
270 | 20
271 |
272 |
273 |
274 |
275 | -
276 |
277 |
-
278 |
279 |
-
280 |
281 |
282 | to DOS
283 |
284 |
285 | true
286 |
287 |
288 |
289 | -
290 |
291 |
292 | to Unix
293 |
294 |
295 |
296 |
297 |
298 | -
299 |
300 |
301 | Skip non-ASCII files
302 |
303 |
304 | true
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 | -
314 |
315 |
-
316 |
317 |
-
318 |
319 |
320 | Direct Input
321 |
322 |
323 |
324 | -
325 |
326 |
327 | Convert
328 |
329 |
330 |
331 |
332 |
333 | -
334 |
335 |
336 |
337 | 0
338 | 0
339 |
340 |
341 |
342 | false
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 | Encryption
353 |
354 |
355 | -
356 |
357 |
358 | Generate Keys
359 |
360 |
361 |
362 | -
363 |
364 |
365 | QTabWidget::West
366 |
367 |
368 | 3
369 |
370 |
371 | false
372 |
373 |
374 |
375 | AES CBC
376 |
377 |
378 |
-
379 |
380 |
-
381 |
382 |
383 | Key
384 |
385 |
386 |
387 | -
388 |
389 |
390 |
391 |
392 | -
393 |
394 |
-
395 |
396 |
397 | Initialization Vector
398 |
399 |
400 |
401 | -
402 |
403 |
404 |
405 |
406 | -
407 |
408 |
-
409 |
410 |
411 | Enabled
412 |
413 |
414 | false
415 |
416 |
417 |
418 | -
419 |
420 |
-
421 |
422 | 128 bits
423 |
424 |
425 | -
426 |
427 | 192 bits
428 |
429 |
430 | -
431 |
432 | 256 bits
433 |
434 |
435 |
436 |
437 | -
438 |
439 |
-
440 |
441 |
442 | Encrypt
443 |
444 |
445 | true
446 |
447 |
448 |
449 | -
450 |
451 |
452 | Decrypt
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 | -
461 |
462 |
463 | Qt::Vertical
464 |
465 |
466 |
467 | 20
468 | 40
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 | Blowfish CBC
478 |
479 |
480 | -
481 |
482 |
-
483 |
484 |
485 | Key
486 |
487 |
488 |
489 | -
490 |
491 |
492 |
493 |
494 | -
495 |
496 |
-
497 |
498 |
499 | Initialization Vector
500 |
501 |
502 |
503 | -
504 |
505 |
506 |
507 |
508 | -
509 |
510 |
-
511 |
512 |
513 | Enabled
514 |
515 |
516 |
517 | -
518 |
519 |
-
520 |
521 |
522 | Encrypt
523 |
524 |
525 | true
526 |
527 |
528 |
529 | -
530 |
531 |
532 | Decrypt
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 | -
541 |
542 |
543 | Qt::Vertical
544 |
545 |
546 |
547 | 20
548 | 40
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 | 3DES CBC
558 |
559 |
560 | -
561 |
562 |
-
563 |
564 |
565 | Key
566 |
567 |
568 |
569 | -
570 |
571 |
572 |
573 |
574 | -
575 |
576 |
-
577 |
578 |
579 | Initialization Vector
580 |
581 |
582 |
583 | -
584 |
585 |
586 |
587 |
588 | -
589 |
590 |
-
591 |
592 |
593 | Enabled
594 |
595 |
596 |
597 | -
598 |
599 |
-
600 |
601 | 2 key
602 |
603 |
604 | -
605 |
606 | 3 key
607 |
608 |
609 |
610 |
611 | -
612 |
613 |
-
614 |
615 |
616 | Encrypt
617 |
618 |
619 | true
620 |
621 |
622 |
623 | -
624 |
625 |
626 | Decrypt
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 | -
635 |
636 |
637 | Qt::Vertical
638 |
639 |
640 |
641 | 20
642 | 252
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 | Twofish CBC
652 |
653 |
654 | -
655 |
656 |
-
657 |
658 |
659 | Key
660 |
661 |
662 |
663 | -
664 |
665 |
666 |
667 |
668 | -
669 |
670 |
-
671 |
672 |
673 | Initialization Vector
674 |
675 |
676 |
677 | -
678 |
679 |
680 |
681 |
682 | -
683 |
684 |
-
685 |
686 |
687 | Enabled
688 |
689 |
690 |
691 | -
692 |
693 |
-
694 |
695 |
696 | Encrypt
697 |
698 |
699 | true
700 |
701 |
702 |
703 | -
704 |
705 |
706 | Decrypt
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 | -
715 |
716 |
717 | Qt::Vertical
718 |
719 |
720 |
721 | 20
722 | 232
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 | Utilities
736 |
737 |
738 | -
739 |
740 |
741 | System Profile
742 |
743 |
744 |
745 | -
746 |
747 |
748 |
749 | 0
750 | 100
751 |
752 |
753 |
754 | ASCII / HEX
755 |
756 |
757 |
-
758 |
759 |
-
760 |
761 |
762 | ASCII
763 |
764 |
765 |
766 | -
767 |
768 |
769 |
770 |
771 | -
772 |
773 |
-
774 |
775 |
776 | HEX
777 |
778 |
779 |
780 | -
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 | -
789 |
790 |
791 | Epoch / Date Conversion
792 |
793 |
794 |
-
795 |
796 |
797 | -
798 |
799 |
800 |
801 |
802 |
803 | -
804 |
805 |
806 | Password Generator
807 |
808 |
809 |
-
810 |
811 |
-
812 |
813 |
814 | -
815 |
816 |
817 | Generate
818 |
819 |
820 |
821 |
822 |
823 | -
824 |
825 |
-
826 |
827 |
828 | Length
829 |
830 |
831 |
832 | -
833 |
834 |
835 | -
836 |
837 |
838 | Caps
839 |
840 |
841 | true
842 |
843 |
844 |
845 | -
846 |
847 |
848 | Nums
849 |
850 |
851 | true
852 |
853 |
854 |
855 | -
856 |
857 |
858 | !#$%^
859 |
860 |
861 | true
862 |
863 |
864 |
865 |
866 |
867 | -
868 |
869 |
870 | Copy Password
871 |
872 |
873 |
874 |
875 |
876 |
877 | -
878 |
879 |
880 | Qt::Vertical
881 |
882 |
883 |
884 | 20
885 | 52
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 | -
895 |
896 |
-
897 |
898 |
899 | -
900 |
901 |
-
902 |
903 |
904 | Delete File Log
905 |
906 |
907 |
908 | -
909 |
910 |
911 | Clear Scroll Log
912 |
913 |
914 |
915 | -
916 |
917 |
918 | Qt::Horizontal
919 |
920 |
921 |
922 | 40
923 | 20
924 |
925 |
926 |
927 |
928 | -
929 |
930 |
931 | Append to cryptoknife.log
932 |
933 |
934 | true
935 |
936 |
937 |
938 | -
939 |
940 |
941 | To Clipboard
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 | -
952 |
953 |
-
954 |
955 |
956 | 24
957 |
958 |
959 |
960 | -
961 |
962 |
963 | Cancel
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
981 |
982 |
983 | TopToolBarArea
984 |
985 |
986 | false
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
--------------------------------------------------------------------------------
/src/mainwindow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of Cryptoknife
3 | *
4 | * Licensed GPL v2
5 | * http://Cryptoknife.com/
6 | *
7 | * Copyright Dan Nagle
8 | *
9 | */
10 |
11 | #include "mainwindow.h"
12 | #include "ui_mainwindow.h"
13 |
14 | #include "crypto.h"
15 |
16 |
17 | #include
18 | #include
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 |
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 |
50 | #include "crc32.h"
51 |
52 | #include "globals.h"
53 | #include "brucethepoodle.h"
54 |
55 | #ifdef __WIN32
56 |
57 | #include
58 | #include
59 |
60 | #endif
61 |
62 | #ifdef __APPLE__
63 | #define SETTINGSFILE QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation )+ "/com.cryptoknife/cryptoknife_settings.ini"
64 | #else
65 | #define SETTINGSFILE "cryptoknife_settings.ini"
66 | #endif
67 | #define SETLOG(var) ui->resultTextEdit->clear(); appendResult(var);
68 |
69 |
70 | #ifdef __APPLE__
71 | #define LOGFILE QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/cryptoknife.log"
72 | #else
73 | #define LOGFILE "cryptoknife.log"
74 | #endif
75 | #define SETLOG(var) ui->resultTextEdit->clear(); appendResult(var);
76 |
77 |
78 |
79 | MainWindow::MainWindow(QWidget *parent) :
80 | QMainWindow(parent),
81 | ui(new Ui::MainWindow)
82 | {
83 | ui->setupUi(this);
84 |
85 | setWindowTitle("Cryptoknife");
86 |
87 | ui->menuBar->hide();
88 | ui->mainToolBar->hide();
89 |
90 | setAcceptDrops(true);
91 |
92 | ui->mainTabWidget->setCurrentIndex(0);
93 |
94 | ui->encryptTabWidget->setCurrentIndex(0);
95 |
96 | ui->resultTextEdit->setAcceptDrops(false);
97 |
98 | ui->progressBar->hide();
99 | ui->cancelButton->hide();
100 |
101 | QIcon mIcon("://logo.png");
102 | setWindowIcon(mIcon);
103 |
104 | //default checked
105 | ui->md5Check->setChecked(true);
106 | ui->sha1Check->setChecked(true);
107 | ui->sha256Check->setChecked(true);
108 |
109 | ui->resultTextEdit->setReadOnly(true);
110 | ui->resultTextEdit->setWordWrapMode(QTextOption::NoWrap);
111 |
112 |
113 | //Bruce is my pet poodle.
114 | //Dog easter egg. CTRL D, O, G.
115 | // or CMD D, O, G.
116 | QShortcut *bruce = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_D,Qt::CTRL + Qt::Key_O, Qt::CTRL + Qt::Key_G ), this);
117 |
118 | if(!connect(bruce, &QShortcut::activated, this, &MainWindow::poodlepic)) {
119 | QDEBUG() << "bruce connection false";
120 | }
121 |
122 |
123 |
124 | QString systemInfo = systemProfile();
125 |
126 | SETLOG(systemInfo);
127 |
128 | systemInfo.prepend("Drag & Drop files and directories here.
\n");
129 | systemInfo.replace("\n", "
");
130 | ui->resultTextEdit->setText(systemInfo);
131 |
132 |
133 |
134 | generateUrlButton("@NagleCode", "https://twitter.com/NagleCode");
135 | generateUrlButton("Cryptoknife.com", "http://cryptoknife.com/");
136 | //generateUrlButton("PacketSender.com", "http://packetsender.com/");
137 |
138 |
139 | epochedit = true;
140 |
141 | QDateTime now = QDateTime::currentDateTime();
142 |
143 | ui->dateTimeEdit->setDateTime(now);
144 | ui->epochEdit->setText(QString::number(now.toSecsSinceEpoch()));
145 | epochedit = false;
146 |
147 | asciiedit = false;
148 |
149 | directHash = false;
150 |
151 | cancel = false;
152 |
153 |
154 | passwordedit = true;
155 | ui->secureLengthCombo->clear();
156 | for(int i=5; i<=30; i++) {
157 | ui->secureLengthCombo->addItem(QString::number(i));
158 | }
159 | ui->secureLengthCombo->setCurrentIndex(ui->secureLengthCombo->findText("15"));
160 | qsrand(static_cast(QTime::currentTime().msec()));
161 | passwordedit = false;
162 |
163 | on_genSecurePWButton_clicked();
164 |
165 | logbuttondisplay();
166 |
167 | statusBar()->showMessage("Version : " SW_VERSION, 3000);
168 |
169 | if(QFile::exists(SETTINGSFILE)) {
170 | processSettings(false);
171 | }
172 |
173 | }
174 |
175 | void MainWindow::logbuttondisplay()
176 | {
177 |
178 | QFileInfo check_file(LOGFILE);
179 |
180 | qint64 filesize = check_file.size();
181 | QString deletetext = "Delete log (";
182 | ui->deleteFileButton->setText(deletetext + QString::number(filesize) + " Bytes)");
183 | if(filesize > (1000)) {
184 | ui->deleteFileButton->setText(deletetext + QString::number(filesize / (1000)) + " KB)");
185 | }
186 | if(filesize > (1000 * 1000)) {
187 | ui->deleteFileButton->setText(deletetext + QString::number(filesize / (1000*1000)) + " MB)");
188 | }
189 | if(filesize > (1000 * 1000*1000)) {
190 | ui->deleteFileButton->setText(deletetext + QString::number(filesize / (1000*1000*1000)) + " GB)");
191 | }
192 |
193 | }
194 |
195 | void MainWindow::poodlepic()
196 | {
197 | QDEBUG();
198 |
199 | BruceThePoodle *bruce = new BruceThePoodle(this);
200 | bruce->show();
201 | }
202 |
203 |
204 | void MainWindow::generateUrlButton(QString name, QString link)
205 | {
206 |
207 | static int buttonindex = 0;
208 |
209 | QString hyperLinkStyle = "QPushButton { color: blue; } QPushButton::hover { color: #BC810C; } ";
210 |
211 |
212 | QPushButton * linkButton = new QPushButton(name);
213 | linkButton->setStyleSheet(hyperLinkStyle);
214 | linkButton->setFlat(true);
215 | linkButton->setProperty("link", link);
216 | linkButton->setCursor(Qt::PointingHandCursor);
217 |
218 | if(!connect(linkButton, &QPushButton::clicked, this, &MainWindow::launchBrowser)) {
219 | QDEBUG() << "field1 connection false";
220 | }
221 |
222 | buttonindex = statusBar()->insertPermanentWidget(buttonindex, linkButton);
223 | buttonindex++;
224 |
225 | }
226 |
227 | void MainWindow::dragEnterEvent(QDragEnterEvent* event)
228 | {
229 | // if some actions should not be usable, like move, this code must be adopted
230 | //QDEBUG();
231 | event->acceptProposedAction();
232 | }
233 |
234 | void MainWindow::dragMoveEvent(QDragMoveEvent* event)
235 | {
236 | // if some actions should not be usable, like move, this code must be adopted
237 | //QDEBUG();
238 | event->acceptProposedAction();
239 | }
240 |
241 | void MainWindow::dragLeaveEvent(QDragLeaveEvent* event)
242 | {
243 | //QDEBUG();
244 | event->accept();
245 | }
246 |
247 |
248 |
249 |
250 | QString MainWindow::doCrypto(QString filename)
251 | {
252 |
253 | Crypto crypto;
254 | crypto.filename = filename;
255 | crypto.domd2 = ui->md2Check->isChecked();
256 | crypto.domd4 = ui->md4Check->isChecked();
257 | crypto.doMD5 = ui->md5Check->isChecked();
258 | crypto.dosha1 = ui->sha1Check->isChecked();
259 | crypto.dosha224 = ui->sha224Check->isChecked();
260 | crypto.dosha256 = ui->sha256Check->isChecked();
261 | crypto.dosha384 = ui->sha384Check->isChecked();
262 | crypto.dosha512 = ui->sha512Check->isChecked();
263 |
264 | appendResult("File: " + filename);
265 |
266 | crypto.doHash();
267 |
268 |
269 | if(ui->checksum8Check->isChecked()) {
270 | quint64 chksum = Crypto::Checksum(filename);
271 | appendResult("Checksum: " + QString::number(chksum, 16).toUpper());
272 | }
273 |
274 | if(ui->crc32Check->isChecked()) {
275 | Crc32 crc32;
276 | quint32 crcresult = crc32.calculateFromFile(filename);
277 | appendResult("CRC32: " + QString::number(crcresult, 16));
278 | }
279 |
280 | if(ui->base64DecCheck->isChecked()) {
281 | QString newFile = filename + ui->base64DecExtEdit->text();
282 | QDEBUGVAR(newFile);
283 | Crypto::Base64Decode(filename.toStdString().c_str(), newFile.toStdString().c_str());
284 | appendResult("Base64 Decoded to:" + newFile);
285 | }
286 |
287 | if(ui->base64EncCheck->isChecked()) {
288 | QString newFile = filename + ui->base64ExtEdit->text();
289 | Crypto::Base64Encode(filename.toStdString().c_str(), newFile.toStdString().c_str());
290 | appendResult("Base64 Encoded to:" + newFile);
291 | }
292 |
293 | if(ui->hexCheck->isChecked()) {
294 | QString newFile = filename + ui->hexExtEdit->text();
295 | crypto.Bin2HEX(filename.toStdString().c_str(), newFile.toStdString().c_str());
296 | appendResult("Bin2HEX to:" + newFile);
297 | }
298 |
299 | if(ui->binCheck->isChecked()) {
300 | QString newFile = filename + ui->binExtEdit->text();
301 | crypto.HEX2Bin(filename.toStdString().c_str(), newFile.toStdString().c_str());
302 | appendResult("HEX2Bin to:" + newFile);
303 | }
304 |
305 |
306 | if(ui->dos2UnixCheck->isChecked()) {
307 | QFile dos2unixFile(filename);
308 |
309 | if(dos2unixFile.open(QFile::ReadOnly)) {
310 | QByteArray theData = dos2unixFile.readAll();
311 | dos2unixFile.close();
312 |
313 | bool isBinary = false;
314 | if(ui->ignoreBinaryCheck->isChecked()) {
315 | for(int i = 0; i < theData.size(); ++i) {
316 | if(((unsigned char) theData.at(i)) > 127) {
317 | isBinary = true;
318 | break;
319 | }
320 | }
321 | if(isBinary) {
322 | appendResult("Skipping non-ASCII file");
323 | }
324 | }
325 |
326 | if(!isBinary) {
327 |
328 | int oldSize = theData.size();
329 | if(ui->dos2UnixRadio->isChecked()) {
330 | appendResult("Converting DOS to Unix");
331 | theData.replace("\r", "");
332 | } else {
333 | appendResult("Converting Unix to DOS");
334 | theData.replace("\r", ""); //remove solitary carriage returns
335 | theData.replace("\n", "\r\n");
336 | }
337 | int newSize = theData.size();
338 | if(dos2unixFile.open(QFile::WriteOnly)) {
339 | dos2unixFile.write(theData);
340 | dos2unixFile.close();
341 | appendResult("Old size:" + QString::number(oldSize) + ", New size:" + QString::number(newSize));
342 |
343 |
344 | }
345 |
346 | }
347 |
348 | }
349 | }
350 |
351 | if(ui->tripleDESCheck->isChecked()) {
352 | crypto.tripleDESKey = ui->tripleDESKeyEdit->text().trimmed().toUpper();
353 | crypto.tripleDESIV = ui->tripleDESIVEdit->text().trimmed().toUpper();
354 | if(ui->encryptDESRadio->isChecked()) {
355 | if(ui->tripleDESVariantCombo->currentText().contains("2")) {
356 | crypto.TripleDES2_CBC_Encrypt(QString(crypto.filename + ".des-ede-cbc").toStdString().c_str());
357 | } else {
358 | crypto.TripleDES3_CBC_Encrypt(QString(crypto.filename + ".des-ede3-cbc").toStdString().c_str());
359 | }
360 |
361 | appendResult("key:" + crypto.tripleDESKey);
362 | appendResult("IV:" + crypto.tripleDESIV);
363 | }
364 |
365 | if(ui->decryptDESRadio->isChecked()) {
366 |
367 | if(ui->tripleDESVariantCombo->currentText().contains("2")) {
368 | crypto.TripleDES2_CBC_Decrypt(QString(crypto.filename + ".decrypted").toStdString().c_str());
369 | } else {
370 | crypto.TripleDES3_CBC_Decrypt(QString(crypto.filename + ".decrypted").toStdString().c_str());
371 | }
372 | appendResult("Decrypting file:" + crypto.filename);
373 | }
374 |
375 | }
376 |
377 | if(ui->blowfishCheck->isChecked()) {
378 | crypto.blowfishKey = ui->bfKeyEdit->text().trimmed().toUpper();
379 | crypto.blowfishIV = ui->bfIVEdit->text().trimmed().toUpper();
380 | if(ui->encryptBlowfishRadio->isChecked()) {
381 | crypto.Blowfish_CBC_Encrypt(QString(crypto.filename + ".blowfish-cbc").toStdString().c_str());
382 | appendResult("key:" + crypto.blowfishKey);
383 | appendResult("IV:" + crypto.blowfishIV);
384 |
385 | }
386 |
387 | if(ui->decryptBlowfishRadio->isChecked()) {
388 | crypto.Blowfish_CBC_Decrypt(QString(crypto.filename + ".decrypted").toStdString().c_str());
389 | appendResult("Decrypting file:" + crypto.filename);
390 | }
391 |
392 | }
393 |
394 |
395 | if(ui->twofishCheck->isChecked()) {
396 | crypto.twofishKey = ui->key2FishEdit->text().trimmed().toUpper();
397 | crypto.twofishIV = ui->iv2FishEdit->text().trimmed().toUpper();
398 | if(ui->encrypt2FishRadio->isChecked()) {
399 | crypto.Twofish_CBC_Encrypt(QString(crypto.filename + ".2fish-cbc").toStdString().c_str());
400 | appendResult("key:" + crypto.twofishKey);
401 | appendResult("IV:" + crypto.twofishIV);
402 |
403 | }
404 |
405 | if(ui->decrypt2FishRadio->isChecked()) {
406 | crypto.Twofish_CBC_Decrypt(QString(crypto.filename + ".decrypted").toStdString().c_str());
407 | appendResult("Decrypting file:" + crypto.filename);
408 | }
409 |
410 | }
411 |
412 |
413 | if(ui->aesCheck->isChecked()) {
414 |
415 | QString bitcheck = ui->aesBitsCombo->currentText().split(" ").first();
416 | crypto.aesBits = bitcheck.toInt();
417 | crypto.aesKey = ui->keyEdit->text().trimmed().toUpper();
418 | crypto.aesIV = ui->ivEdit->text().trimmed().toUpper();
419 |
420 | if(ui->encryptAESRadio->isChecked()) {
421 | QString newFileExt = ".aes-" + QString::number(crypto.aesBits) + "-cbc";
422 | crypto.AES_CBC_Encrypt(QString(crypto.filename + newFileExt).toStdString().c_str());
423 | appendResult("key:" + crypto.aesKey);
424 | appendResult("IV:" + crypto.aesIV);
425 |
426 | }
427 |
428 | if(ui->decryptAESRadio->isChecked()) {
429 | crypto.AES_CBC_Decrypt(QString(crypto.filename + ".decrypted").toStdString().c_str());
430 | appendResult("Decrypting file:" + crypto.filename);
431 | }
432 |
433 |
434 | }
435 | return crypto.result;
436 |
437 | }
438 |
439 | void MainWindow::appendResult(QString result)
440 | {
441 | if(result.isEmpty()) return;
442 |
443 | if(ui->saveDownloadsLogCheck->isChecked()) {
444 | QFile logFile(LOGFILE);
445 | if(logFile.open(QFile::Append)) {
446 | logFile.write(QString("\r\n" + result).toLatin1());
447 | logFile.close();
448 | logbuttondisplay();
449 | }
450 | }
451 |
452 |
453 | QString currentText = ui->resultTextEdit->toPlainText();
454 | ui->resultTextEdit->setText(currentText + "\n" + result.trimmed());
455 | }
456 |
457 |
458 | void MainWindow::processSettings(bool save)
459 | {
460 | QCheckBox * checkbox;
461 | QLineEdit * lineedit;
462 | QComboBox * combo;
463 | QRadioButton * radio;
464 | QTextEdit * text;
465 |
466 | QSettings settings(SETTINGSFILE, QSettings::IniFormat);
467 | QList checkboxes = ui->centralWidget->findChildren();
468 | QList lineedits = ui->encodingGroupBox->findChildren();
469 | QList combos = ui->centralWidget->findChildren();
470 | QList radios = ui->centralWidget->findChildren();
471 | QList texts = ui->mainTabWidget->findChildren();
472 |
473 |
474 |
475 | foreach(checkbox, checkboxes) {
476 | if(save) {
477 | settings.setValue(checkbox->objectName(), checkbox->isChecked());
478 | } else {
479 | checkbox->setChecked(settings.value(checkbox->objectName(), false).toBool());
480 | }
481 | }
482 |
483 | foreach(combo, combos) {
484 | if(save) {
485 | settings.setValue(combo->objectName(), combo->currentText());
486 | } else {
487 | QString value = settings.value(combo->objectName(), "").toString();
488 | int index = combo->findText(value);
489 | if(index > -1) {
490 | combo->setCurrentIndex(index);
491 | }
492 |
493 | }
494 | }
495 |
496 | foreach(radio, radios) {
497 | if(save) {
498 | settings.setValue(radio->objectName(), radio->isChecked());
499 | } else {
500 | radio->setChecked(settings.value(radio->objectName(), false).toBool());
501 | }
502 | }
503 |
504 | foreach(lineedit, lineedits) {
505 | if(save) {
506 | settings.setValue(lineedit->objectName(), lineedit->text());
507 | } else {
508 | lineedit->setText(settings.value(lineedit->objectName(), "").toString());
509 | }
510 | }
511 |
512 | foreach(text, texts) {
513 | if(save) {
514 | settings.setValue(text->objectName(), text->toPlainText());
515 | } else {
516 | text->setText(settings.value(text->objectName(), "").toString());
517 | }
518 | }
519 |
520 |
521 | }
522 |
523 |
524 | void MainWindow::launchBrowser()
525 | {
526 |
527 | QObject* obj = sender();
528 | QString link = obj->property("link").toString();
529 | QDesktopServices::openUrl(QUrl(link));
530 | }
531 |
532 | void MainWindow::dropEvent(QDropEvent* event)
533 | {
534 |
535 | ui->resultTextEdit->clear();
536 | QStringList filePathList;
537 | if (event->mimeData()->hasUrls())
538 | {
539 | foreach (QUrl url, event->mimeData()->urls())
540 | {
541 | filePathList << url.toLocalFile();
542 | }
543 | }
544 |
545 | QDEBUG() << filePathList;
546 |
547 | QString file, hashFile;
548 | foreach(file, filePathList) {
549 |
550 | QStringList iterateList;iterateList.clear();
551 |
552 | QFileInfo check_file(file);
553 |
554 | if(check_file.exists() && check_file.isDir()) {
555 | QDirIterator it(file, QDirIterator::Subdirectories);
556 | while (it.hasNext()) {
557 | QString fileString = it.next();
558 | QFileInfo check_file2(fileString);
559 | if(check_file2.exists() && check_file2.isFile()) {
560 | iterateList << fileString;
561 | }
562 | }
563 | } else {
564 |
565 | if(check_file.exists() && check_file.isFile()) {
566 | iterateList << file;
567 | }
568 | }
569 |
570 |
571 | QElapsedTimer timer;
572 | timer.start();
573 | ui->progressBar->setValue(0);
574 | ui->progressBar->setMinimum(0);
575 | ui->progressBar->setMaximum(iterateList.size());
576 | ui->progressBar->show();
577 | ui->cancelButton->show();
578 | cancel = false;
579 |
580 | for(int index=0; indexprogressBar->setValue(index);
584 | QApplication::processEvents();
585 | appendResult(doCrypto(hashFile));
586 |
587 | if(cancel) {
588 | appendResult("Progress cancelled.");
589 | break;
590 | }
591 |
592 | }
593 |
594 | ui->progressBar->hide();
595 | ui->cancelButton->hide();
596 | cancel = false;
597 | appendResult("Finished in " + QString::number(timer.elapsed()) + " milliseconds.");
598 |
599 |
600 | }
601 |
602 |
603 | }
604 |
605 |
606 | MainWindow::~MainWindow()
607 | {
608 |
609 | processSettings(true);
610 | delete ui;
611 | }
612 |
613 | bool MainWindow::openFiles(const QStringList &pathList)
614 | {
615 | QDEBUG() << pathList;
616 |
617 | return true;
618 | }
619 |
620 | void MainWindow::on_epochEdit_textEdited(const QString &arg1)
621 | {
622 | if(epochedit) return;
623 | epochedit = true;
624 | qint64 newtime = arg1.toLong();
625 | QDateTime newnow;
626 | newnow.setSecsSinceEpoch(newtime);
627 | ui->dateTimeEdit->setDateTime(newnow);
628 | epochedit = false;
629 |
630 | }
631 |
632 | void MainWindow::on_dateTimeEdit_dateTimeChanged(const QDateTime &dateTime)
633 | {
634 | if(epochedit) return;
635 | epochedit = true;
636 | ui->epochEdit->setText(QString::number(dateTime.toSecsSinceEpoch()));
637 | epochedit = false;
638 | }
639 |
640 |
641 | int hexToInt(QChar hex)
642 | {
643 | hex = hex.toLower();
644 |
645 | if(hex == 'f')
646 | {
647 | return 15;
648 | }
649 | if(hex == 'e')
650 | {
651 | return 14;
652 | }
653 | if(hex == 'd')
654 | {
655 | return 13;
656 | }
657 | if(hex == 'c')
658 | {
659 | return 12;
660 | }
661 | if(hex == 'b')
662 | {
663 | return 11;
664 | }
665 | if(hex == 'a')
666 | {
667 | return 10;
668 | }
669 |
670 | return hex.digitValue();
671 |
672 | }
673 |
674 | QString ASCIITohex(QString &ascii)
675 | {
676 | if(ascii.isEmpty())
677 | {
678 | return "";
679 | }
680 |
681 | QString asciiText = ascii;
682 | QString hexText = "";
683 | QChar tempChar1, tempChar2;
684 | QChar charTest;
685 | QString convertTest;
686 | bool msb = false;
687 | bool lsb = false;
688 | int lsbInt = 0;
689 | int msbInt = 0;
690 |
691 | // qDebug() << __FILE__ << "/" << __LINE__;
692 |
693 | //convert special sequences to raw numbers.
694 | asciiText.replace("\\\\", "\\" + QString::number('\\', 16));
695 | asciiText.replace("\\n", "\\0" + QString::number('\n', 16));
696 | asciiText.replace("\\r", "\\0" + QString::number('\r', 16));
697 | asciiText.replace("\\t", "\\0" + QString::number('\t', 16));
698 |
699 | // qDebug() << __FILE__ << "/" << __LINE__;
700 | if(asciiText.size() > 0)
701 | {
702 | if(asciiText.at(asciiText.size()-1) == '\\') //last char is a slash
703 | {
704 | asciiText.append("00");
705 | }
706 | }
707 |
708 | // qDebug() << __FILE__ << "/" << __LINE__;
709 | if(asciiText.size() > 2)
710 | {
711 | if(asciiText.at(asciiText.size()-2) == '\\') //second last char is a slash
712 | {
713 | //slide 0 in between
714 |
715 | // qDebug() << __FILE__ << "/" << __LINE__ <<"second last is slash";
716 |
717 | charTest = asciiText.at(asciiText.size()-1);
718 | asciiText[asciiText.size()-1] = '0';
719 | asciiText.append(charTest);
720 | }
721 | }
722 | // qDebug() << __FILE__ << "/" << __LINE__ <<"analyze" << asciiText;
723 |
724 |
725 | for (int i = 0 ; i < asciiText.size(); i++)
726 | {
727 | msb = false;
728 | lsb = false;
729 | lsbInt = 0;
730 | msbInt = 0;
731 |
732 | charTest = asciiText.at(i);
733 |
734 | // qDebug() << __FILE__ << "/" << __LINE__ <<"checking" << charTest;
735 |
736 | if(charTest == '\\')
737 | {
738 | // qDebug() << __FILE__ << "/" << __LINE__ <<"found slash";
739 | if(i + 1 < asciiText.size())
740 | {
741 | msbInt = hexToInt(asciiText.at(i + 1));
742 | if(msbInt > -1)
743 | {
744 | msb = true;
745 | }
746 | // qDebug() << __FILE__ << "/" << __LINE__ <<"msb convert test is" << msb;
747 |
748 | }
749 | if(i + 2 < asciiText.size())
750 | {
751 | lsbInt = hexToInt(asciiText.at(i + 2));
752 | if(lsbInt > -1)
753 | {
754 | lsb = true;
755 | }
756 | // qDebug() << __FILE__ << "/" << __LINE__ <<"lsb convert test is" << lsb;
757 | }
758 |
759 | if(msb)
760 | {
761 | hexText.append(QString::number(msbInt, 16));
762 | // qDebug() << __FILE__ << "/" << __LINE__ <<"hexText append result" << hexText;
763 | i++;
764 | }
765 |
766 | if(lsb)
767 | {
768 | hexText.append(QString::number(lsbInt, 16));
769 | // qDebug() << __FILE__ << "/" << __LINE__ <<"hexText append" << hexText;
770 | i++;
771 | }
772 |
773 | } else {
774 | // qDebug() << __FILE__ << "/" << __LINE__ <<"no slash";
775 | lsbInt = ((int) charTest.toLatin1()) & 0xff;
776 | if(lsbInt > 0 && lsbInt < 16)
777 | {
778 | hexText.append("0");
779 | }
780 | hexText.append(QString::number(lsbInt, 16));
781 | // qDebug() << __FILE__ << "/" << __LINE__ <<"appended lsbInt:" << QString::number(lsbInt, 16);
782 | }
783 |
784 | hexText.append(" ");
785 | // qDebug() << __FILE__ << "/" << __LINE__ <<"hex test now " << hexText;
786 |
787 | }
788 |
789 | return hexText;
790 |
791 | }
792 |
793 |
794 | QString hexToASCII(QString &hex)
795 | {
796 |
797 |
798 | QStringList hexSplit;
799 |
800 | //remove invalid characters of popular deliminators...
801 | hex = hex.replace(",", " ");
802 | hex = hex.replace(".", " ");
803 | hex = hex.replace(":", " ");
804 | hex = hex.replace(";", " ");
805 | hex = hex.replace("0x", " ");
806 | hex = hex.replace("x", " ");
807 | hex = hex.replace("\n", " ");
808 | hex = hex.replace("\r", " ");
809 | hex = hex.replace("\t", " ");
810 |
811 | QString hexText = hex.simplified();
812 | if(hexText.isEmpty())
813 | {
814 | return "";
815 | }
816 |
817 | if((hexText.size() % 2 != 0)) {
818 | //Not divisible by 2. What should I do?
819 | if(!hexText.contains(" ") && hexText.size() > 2)
820 | {
821 | //Seems to be one big hex stream. Front-load it with a 0.
822 | hexText.prepend("0");
823 | }
824 |
825 | }
826 |
827 |
828 | if(!hexText.contains(" ") && hexText.size() > 2 && hexText.size() % 2 == 0)
829 | {
830 | //does not contain any spaces. Maybe one big hex stream?
831 | QDEBUG() << "no spaces" << "even digits";
832 | QStringList hexList;
833 | hexList.clear();
834 | QString append;
835 | append.clear();
836 | for(int i =0; i < hexText.size(); i+=2)
837 | {
838 | append.clear();
839 | append.append(hexText[i]);
840 | append.append(hexText[i + 1]);
841 | hexList << append;
842 | }
843 | hexText = hexList.join(" ").trimmed();
844 | hex = hexText;
845 | }
846 |
847 | hexSplit = hexText.split(" ");
848 | QString asciiText = "";
849 | unsigned int convertInt;
850 | bool ok = false;
851 | int malformed = 0;
852 | bool malformedBool = false;
853 | QChar malformedChar;
854 |
855 |
856 | QString checkSpace = hex.at(hex.size() - 1);
857 | if(checkSpace == " ")
858 | {
859 | hexText.append(" ");
860 | }
861 |
862 | hex = hexText;
863 |
864 | // qDebug() << __FILE__ << "/" << __LINE__ << __FUNCTION__ <<"analyze hex split" << hexSplit;
865 |
866 | for(int i=0; i< hexSplit.size(); i++)
867 | {
868 | if(hexSplit.at(i).size() > 2)
869 | {
870 | malformedBool = true;
871 | malformed = i;
872 | malformedChar = hexSplit.at(i).at(2);
873 | // qDebug() << __FILE__ << "/" << __LINE__ << __FUNCTION__ << "malformed at"<< QString::number(i) << "is" << malformedChar;
874 | break;
875 | }
876 |
877 | }
878 |
879 | if(malformedBool)
880 | {
881 | QString fixText = "";
882 | QString testChar;
883 |
884 | for(int i = 0; i < malformed; i++)
885 | {
886 | fixText.append(hexSplit.at(i));
887 | fixText.append(" ");
888 | }
889 |
890 |
891 | testChar.append(malformedChar);
892 | testChar.toUInt(&ok, 16);
893 |
894 | // qDebug() << __FILE__ << "/" << __LINE__ << __FUNCTION__ << "malformed digitvalue" << malformedChar.digitValue();
895 |
896 | if(ok)
897 | {
898 | fixText.append(hexSplit.at(malformed).at(0));
899 | fixText.append(hexSplit.at(malformed).at(1));
900 | fixText.append(" ");
901 | fixText.append(malformedChar);
902 | }
903 | hexText = (fixText.simplified());
904 | hex = hexText;
905 | hexSplit = hexText.split(" ");
906 | }
907 |
908 |
909 |
910 | for(int i=0; i< hexSplit.size(); i++)
911 | {
912 | convertInt = hexSplit.at(i).toUInt(&ok, 16);
913 | // qDebug() << __FILE__ << "/" << __LINE__ << __FUNCTION__ <<"hex at"<< QString::number(i) << "is" << QString::number(convertInt);
914 | if(ok)
915 | {
916 | if(convertInt >= 0x20 && convertInt <= 0x7e && convertInt != '\\')
917 | {
918 | // qDebug() << __FILE__ << "/" << __LINE__ << __FUNCTION__ << "Converted to " << QChar(convertInt);
919 | asciiText.append((QChar(convertInt)));
920 | } else {
921 | asciiText.append("\\");
922 | switch((char)convertInt)
923 | {
924 | case '\n':
925 | asciiText.append("n");
926 | break;
927 | case '\r':
928 | asciiText.append("r");
929 | break;
930 | case '\t':
931 | asciiText.append("t");
932 | break;
933 | case '\\':
934 | asciiText.append("\\");
935 | break;
936 | default:
937 | if(convertInt < 16)
938 | {
939 | asciiText.append("0");
940 | }
941 | asciiText.append(QString::number(convertInt, 16));
942 | break;
943 |
944 | }
945 |
946 | }
947 |
948 | } else {
949 | // qDebug() << __FILE__ << "/" << __LINE__ << __FUNCTION__ << "Convert failed";
950 | hexSplit[i] = "";
951 | hex = (hexSplit.join(" "));
952 | }
953 |
954 | }
955 |
956 |
957 | return asciiText;
958 |
959 | }
960 |
961 |
962 | void MainWindow::on_asciiEdit_textChanged(const QString &arg1)
963 | {
964 | if(asciiedit) return;
965 |
966 | asciiedit = true;
967 | QString updated = arg1;
968 | QString hex = ASCIITohex(updated);
969 | ui->hexEdit->setText(hex);
970 |
971 | asciiedit = false;
972 | }
973 |
974 | void MainWindow::on_hexEdit_textEdited(const QString &arg1)
975 | {
976 | if(asciiedit) return;
977 |
978 | asciiedit = true;
979 | QString updated = arg1;
980 | QString hex = hexToASCII(updated);
981 | ui->asciiEdit->setText(hex);
982 |
983 | asciiedit = false;
984 | }
985 |
986 | void MainWindow::on_cancelButton_clicked()
987 | {
988 | cancel = true;
989 | }
990 |
991 | QStringList MainWindow::magicNumbersToFile(QByteArray initialbytes)
992 | {
993 | //https://en.wikipedia.org/wiki/List_of_file_signatures
994 | }
995 |
996 | void MainWindow::on_deriveButton_clicked()
997 | {
998 | static QString originalText = ui->deriveButton->text();
999 |
1000 | QHash keys;
1001 | QHash IVs;
1002 |
1003 | Crypto::GenerateKeys(keys, IVs);
1004 |
1005 |
1006 | QString bitcheck = ui->aesBitsCombo->currentText().split(" ").first();
1007 | QString aescipher= "aes-" + bitcheck + "-cbc";
1008 | ui->keyEdit->setText(keys[aescipher]);
1009 | ui->ivEdit->setText(IVs[aescipher]);
1010 |
1011 | ui->bfKeyEdit->setText(keys["bf-cbc"]);
1012 | ui->bfIVEdit->setText(IVs["bf-cbc"]);
1013 |
1014 | ui->key2FishEdit->setText(keys["twofish"]);
1015 | ui->iv2FishEdit->setText(IVs["twofish"]);
1016 |
1017 | if(ui->tripleDESVariantCombo->currentText().contains("2")) {
1018 |
1019 | ui->tripleDESKeyEdit->setText(keys["des-ede-cbc"]);
1020 | ui->tripleDESIVEdit->setText(IVs["des-ede-cbc"]);
1021 |
1022 | } else {
1023 | ui->tripleDESKeyEdit->setText(keys["des-ede3-cbc"]);
1024 | ui->tripleDESIVEdit->setText(IVs["des-ede3-cbc"]);
1025 |
1026 | }
1027 |
1028 | ui->deriveButton->setText(originalText);
1029 |
1030 | }
1031 |
1032 | void MainWindow::on_clearLogButton_clicked()
1033 | {
1034 | ui->resultTextEdit->clear();
1035 | }
1036 |
1037 | void MainWindow::on_toClipBoardButton_clicked()
1038 | {
1039 |
1040 | QClipboard *clipboard = QApplication::clipboard();
1041 | clipboard->setText(ui->resultTextEdit->toPlainText());
1042 |
1043 | statusBar()->showMessage("Copied to clipboard", 3000);
1044 |
1045 | }
1046 |
1047 | void MainWindow::on_hashCalcButton_clicked()
1048 | {
1049 |
1050 | #ifdef Q_OS_MAC
1051 | //Mac cannot easily create files in app directory
1052 | QTemporaryFile temporaryFile;
1053 | #else
1054 | QTemporaryFile temporaryFile("cryptofile-temp");
1055 | #endif
1056 |
1057 | if(temporaryFile.open()) {
1058 | QString tempText = ui->directInputHashEdit->toPlainText();
1059 | temporaryFile.write(tempText.toUtf8());
1060 | temporaryFile.close();
1061 | }
1062 |
1063 | QString filename = temporaryFile.fileName();
1064 |
1065 | QFile tempFile(filename);
1066 | QDEBUGVAR(filename);
1067 |
1068 | if(filename.isEmpty()) {
1069 | QDEBUG() << "Filename is blank";
1070 | return;
1071 | }
1072 |
1073 | if(tempFile.exists()) {
1074 |
1075 | Crypto crypto;
1076 | crypto.filename = filename;
1077 | crypto.domd2 = true;
1078 | crypto.domd4 = true;
1079 | crypto.doMD5 = true;
1080 | crypto.dosha1 = true;
1081 | crypto.dosha224 = true;
1082 | crypto.dosha256 = true;
1083 | crypto.dosha384 = true;
1084 | crypto.dosha512 = true;
1085 | crypto.doHash();
1086 | ui->resultTextEdit->clear();
1087 | Crc32 crc32;
1088 | quint32 crcresult = crc32.calculateFromFile(filename);
1089 | appendResult("CRC32: " + QString::number(crcresult, 16));
1090 | quint64 chksum = Crypto::Checksum(filename);
1091 | appendResult("Checksum: " + QString::number(chksum, 16).toUpper());
1092 | appendResult(crypto.result);
1093 | }
1094 |
1095 | }
1096 |
1097 | void MainWindow::on_encodeCalcButton_clicked()
1098 | {
1099 | #ifdef Q_OS_MAC
1100 | //Mac cannot easily create files in app directory
1101 | QTemporaryFile temporaryIn;
1102 | QTemporaryFile temporaryOut;
1103 | #else
1104 | QTemporaryFile temporaryIn("cryptofile-temp-in");
1105 | QTemporaryFile temporaryOut("cryptofile-temp-in");
1106 |
1107 | #endif
1108 |
1109 | if(temporaryIn.open()) {
1110 | QString tempText = ui->directInputEncodeEdit->toPlainText();
1111 | temporaryIn.write(tempText.toUtf8());
1112 | temporaryIn.close();
1113 | }
1114 |
1115 | if(temporaryOut.open()) {
1116 | temporaryIn.close();
1117 | }
1118 |
1119 | QString fileIn = temporaryIn.fileName();
1120 | QString fileOut = temporaryOut.fileName();
1121 |
1122 | QFile tempFileIn(fileIn);
1123 | QFile tempFileOut(fileOut);
1124 | QDEBUGVAR(fileIn);
1125 |
1126 | if(fileIn.isEmpty()) {
1127 | QDEBUG() << "fileIn is blank";
1128 | return;
1129 | }
1130 |
1131 | if(fileOut.isEmpty()) {
1132 | QDEBUG() << "fileOut is blank";
1133 | return;
1134 | }
1135 |
1136 | QString preserveText = ui->resultTextEdit->toPlainText();
1137 |
1138 | ui->resultTextEdit->clear();
1139 |
1140 | if(tempFileIn.exists()) {
1141 | bool didit = false;
1142 | if(ui->base64DecCheck->isChecked()) {
1143 | didit = true;
1144 | Crypto::Base64Decode(fileIn.toLatin1().data(), fileOut.toLatin1().data());
1145 | if(tempFileOut.open(QFile::ReadOnly)) {
1146 | appendResult(QString(tempFileOut.readAll()));
1147 | tempFileOut.close();
1148 | }
1149 | }
1150 | if(ui->base64EncCheck->isChecked()) {
1151 | didit = true;
1152 | Crypto::Base64Encode(fileIn.toLatin1().data(), fileOut.toLatin1().data());
1153 | if(tempFileOut.open(QFile::ReadOnly)) {
1154 | appendResult(QString(tempFileOut.readAll()));
1155 | tempFileOut.close();
1156 | }
1157 | }
1158 | if(ui->hexCheck->isChecked()) {
1159 | didit = true;
1160 | Crypto::Bin2HEX(fileIn.toLatin1().data(), fileOut.toLatin1().data());
1161 | if(tempFileOut.open(QFile::ReadOnly)) {
1162 | appendResult(QString(tempFileOut.readAll()));
1163 | tempFileOut.close();
1164 | }
1165 | }
1166 | if(ui->binCheck->isChecked()) {
1167 | didit = true;
1168 | Crypto::HEX2Bin(fileIn.toLatin1().data(), fileOut.toLatin1().data());
1169 | if(tempFileOut.open(QFile::ReadOnly)) {
1170 | appendResult(QString(tempFileOut.readAll()));
1171 | tempFileOut.close();
1172 | }
1173 | }
1174 |
1175 | if(!didit) {
1176 | ui->resultTextEdit->append(preserveText);
1177 | QMessageBox msgBox;
1178 | msgBox.setWindowTitle("No encodings.");
1179 | msgBox.setStandardButtons(QMessageBox::Ok);
1180 | msgBox.setDefaultButton(QMessageBox::Ok);
1181 | msgBox.setIcon(QMessageBox::Warning);
1182 | msgBox.setText("Please check at least 1 encoding.");
1183 | msgBox.exec();
1184 |
1185 | }
1186 |
1187 | }
1188 |
1189 |
1190 | }
1191 |
1192 | QString MainWindow::systemProfile()
1193 | {
1194 | QString systemInfo = "Your system information\n";
1195 | systemInfo += QSysInfo::prettyProductName() + " / " + QSysInfo::kernelType() + " " + QSysInfo::kernelVersion() + "\n";
1196 | systemInfo += "Computer name:" + QSysInfo::machineHostName() + "\n";
1197 |
1198 |
1199 | systemInfo += "CPU arch is " + QSysInfo::currentCpuArchitecture() + " and is ";
1200 | if(QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
1201 | systemInfo += "Little Endian\n";
1202 | }
1203 | if(QSysInfo::ByteOrder == QSysInfo::BigEndian) {
1204 | systemInfo += "Big Endian\n";
1205 | }
1206 |
1207 | #ifdef __WIN32
1208 | //Extended processor info...
1209 | int CPUInfo[4] = {-1};
1210 | unsigned nExIds, i = 0;
1211 | char CPUBrandString[0x100];
1212 | // Get the information associated with each extended ID.
1213 | __cpuid(CPUInfo, 0x80000000);
1214 | nExIds = CPUInfo[0];
1215 | for (i=0x80000000; i<=nExIds; ++i)
1216 | {
1217 | __cpuid(CPUInfo, i);
1218 | // Interpret CPU brand string
1219 | if (i == 0x80000002)
1220 | memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
1221 | else if (i == 0x80000003)
1222 | memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
1223 | else if (i == 0x80000004)
1224 | memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
1225 | }
1226 | //string includes manufacturer, model and clockspeed
1227 | systemInfo += "CPU Type: " + QString(CPUBrandString) + "\n";
1228 |
1229 | #endif
1230 |
1231 |
1232 | //SO: http://stackoverflow.com/questions/8122277/getting-memory-information-with-qt
1233 | #ifdef __WIN32
1234 | MEMORYSTATUSEX memory_status;
1235 | ZeroMemory(&memory_status, sizeof(MEMORYSTATUSEX));
1236 | memory_status.dwLength = sizeof(MEMORYSTATUSEX);
1237 | if (GlobalMemoryStatusEx(&memory_status)) {
1238 | if(memory_status.ullTotalPhys > (1024 * 1024 * 1024)) {
1239 | QDEBUGVAR(memory_status.ullTotalPhys);
1240 | systemInfo.append(
1241 | QString("\nRAM: %1 GiB")
1242 | .arg(((float) memory_status.ullTotalPhys) / (1024 * 1024 * 1024)));
1243 | } else {
1244 | systemInfo.append(
1245 | QString("\nRAM: %1 MiB")
1246 | .arg(((float) memory_status.ullTotalPhys) / (1024 * 1024)));
1247 |
1248 | }
1249 |
1250 | } else {
1251 | systemInfo.append("\nUnknown RAM");
1252 | }
1253 |
1254 |
1255 | #endif
1256 |
1257 | #if __linux__
1258 |
1259 | if(QFile::exists("/proc/meminfo")) {
1260 | QProcess p;
1261 | p.start("awk", QStringList() << "/MemTotal/ { print $2 }" << "/proc/meminfo");
1262 | p.waitForFinished();
1263 | QString memory = p.readAllStandardOutput();
1264 | systemInfo.append(QString("; RAM: %1 MB").arg(memory.toLong() / 1024));
1265 | p.close();
1266 | }
1267 |
1268 |
1269 | #endif
1270 | #if __APPLE__
1271 | QProcess p;
1272 | p.start("sysctl", QStringList() << "kern.version" << "hw.physmem");
1273 | p.waitForFinished();
1274 | systemInfo += p.readAllStandardOutput();
1275 | p.close();
1276 | #endif
1277 | systemInfo.append("\n");
1278 |
1279 | QFileInfoList drives = QDir::drives();
1280 |
1281 |
1282 | #ifdef __WIN32
1283 | systemInfo.append("\nMounted drives...\n");
1284 | #endif
1285 |
1286 | QFileInfo drive;
1287 | foreach(drive, drives) {
1288 | QStorageInfo storage(drive.absoluteFilePath());
1289 |
1290 | if(storage.bytesTotal() < 1) {
1291 | continue;
1292 | }
1293 |
1294 | systemInfo += storage.name() + " " + storage.rootPath() + " (" + QString(storage.fileSystemType()) + ") \n";
1295 | quint64 bytesTotal = storage.bytesTotal()/1000/1000;
1296 | float bytesTotalf = ((float) bytesTotal);
1297 | if(bytesTotal > 1000) {
1298 | systemInfo += "Size: " + QString::number(bytesTotalf / 1000) + " GB\n";
1299 | } else {
1300 | systemInfo += "Size: " + QString::number(bytesTotalf) + " MB\n";
1301 | }
1302 |
1303 |
1304 | bytesTotal = storage.bytesAvailable()/1000/1000;
1305 | bytesTotalf = ((float) bytesTotal);
1306 |
1307 | if(bytesTotal > 1000) {
1308 | systemInfo += "Available: " + QString::number(bytesTotalf / 1000) + " GB\n\n";
1309 | } else {
1310 | systemInfo += "Available: " + QString::number(bytesTotalf) + " MB\n\n";
1311 | }
1312 |
1313 | }
1314 |
1315 |
1316 |
1317 | QList allInterfaces = QNetworkInterface::allInterfaces();
1318 | QNetworkInterface eth;
1319 |
1320 |
1321 | QString startLog = "Your non-loopback addresses: \n";
1322 | QTextStream out (&startLog);
1323 |
1324 | foreach(eth, allInterfaces) {
1325 | QList allEntries = eth.addressEntries();
1326 | if(allEntries.size() == 0 || !eth.flags().testFlag(QNetworkInterface::IsUp)) {
1327 | continue;
1328 | }
1329 |
1330 | QString ethString;
1331 | QTextStream ethOut (ðString);
1332 |
1333 |
1334 | ethOut << "\nFor " << eth.humanReadableName() << " (" << eth.hardwareAddress() <<")" << ":\n";
1335 | QNetworkAddressEntry entry;
1336 |
1337 | int nonLoopBack = 0;
1338 |
1339 | foreach (entry, allEntries) {
1340 | if(!entry.ip().isLoopback()) {
1341 | if(entry.ip().toString().contains(":")) {
1342 |
1343 | //ignore ipv6 for now
1344 | //continue;
1345 | }
1346 | nonLoopBack = 1;
1347 | ethOut << entry.ip().toString() << " / " << entry.netmask().toString() << "\n";
1348 | }
1349 | }
1350 |
1351 | if(nonLoopBack) {
1352 | out << ethString;
1353 | }
1354 | }
1355 |
1356 |
1357 | systemInfo.append(startLog);
1358 |
1359 | return systemInfo;
1360 |
1361 | }
1362 |
1363 | int getRandomNumber(const int Min, const int Max)
1364 | {
1365 | return ((qrand() % ((Max + 1) - Min)) + Min);
1366 | }
1367 |
1368 | void MainWindow::on_genSecurePWButton_clicked()
1369 | {
1370 | if(passwordedit) return;
1371 |
1372 | unsigned int length = ui->secureLengthCombo->currentText().toUInt();
1373 | bool caps = ui->secureCapsCheck->isChecked();
1374 | bool special = ui->secureSpecialCheck->isChecked();
1375 | bool nums = ui->secureNumsCheck->isChecked();
1376 | QString pw; pw.clear();
1377 | QString specials = "!#$%^*_";
1378 |
1379 |
1380 | for (unsigned int i=0; isecurePWEdit->setText(pw);
1409 |
1410 | }
1411 |
1412 |
1413 |
1414 |
1415 | void MainWindow::on_systemProfileButton_clicked()
1416 | {
1417 | SETLOG(systemProfile());
1418 | }
1419 |
1420 | void MainWindow::on_copyPWButton_clicked()
1421 | {
1422 | QClipboard *clipboard = QApplication::clipboard();
1423 | clipboard->setText(ui->securePWEdit->text());
1424 | statusBar()->showMessage("Password copied to clipboard", 3000);
1425 | }
1426 |
1427 | void MainWindow::on_secureLengthCombo_currentIndexChanged(int index)
1428 | {
1429 | Q_UNUSED(index);
1430 | on_genSecurePWButton_clicked();
1431 | }
1432 |
1433 | void MainWindow::on_secureCapsCheck_toggled(bool checked)
1434 | {
1435 | Q_UNUSED(checked);
1436 | on_genSecurePWButton_clicked();
1437 |
1438 | }
1439 |
1440 | void MainWindow::on_secureSpecialCheck_toggled(bool checked)
1441 | {
1442 | Q_UNUSED(checked);
1443 | on_genSecurePWButton_clicked();
1444 | }
1445 |
1446 | void MainWindow::on_secureNumsCheck_toggled(bool checked)
1447 | {
1448 | Q_UNUSED(checked);
1449 | on_genSecurePWButton_clicked();
1450 |
1451 | }
1452 |
1453 | void MainWindow::on_aesBitsCombo_currentIndexChanged(const QString &arg1)
1454 | {
1455 | static QString originalText = ui->deriveButton->text();
1456 | QDEBUGVAR(arg1);
1457 | if(arg1.contains("192") || arg1.contains("256")) {
1458 | if(ui->keyEdit->text().size() < QString("8660569170A6AD92CCB806E50FDB0C242F3B01DEB6F9BCF0E916F96B8FD5F7B1").size()) {
1459 | ui->deriveButton->setText("! " + originalText );
1460 |
1461 | }
1462 | }
1463 |
1464 | }
1465 |
1466 | void MainWindow::on_tripleDESVariantCombo_currentIndexChanged(const QString &arg1)
1467 | {
1468 | static QString originalText = ui->deriveButton->text();
1469 | QDEBUGVAR(arg1);
1470 | if(arg1.contains("3")) {
1471 | if(ui->keyEdit->text().size() < QString("90EB9DE3C7F731C31B08AB9AADFB0BB83F7D8E75F0D46DBA").size()) {
1472 | ui->deriveButton->setText("! " + originalText );
1473 |
1474 | }
1475 | }
1476 |
1477 | }
1478 |
1479 | void MainWindow::on_deleteFileButton_clicked()
1480 | {
1481 | if(QFile::remove(LOGFILE)) {
1482 | statusBar()->showMessage("cryptoknife.log deleted", 3000);
1483 | }
1484 |
1485 | logbuttondisplay();
1486 | }
1487 |
--------------------------------------------------------------------------------