Skip to content

Commit 32a58c4

Browse files
committed
提交代码
1 parent cb0ee57 commit 32a58c4

20 files changed

Lines changed: 66092 additions & 39 deletions

.gitignore

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,3 @@
1-
# C++ objects and libs
2-
3-
*.slo
4-
*.lo
5-
*.o
6-
*.a
7-
*.la
8-
*.lai
9-
*.so
10-
*.dll
11-
*.dylib
12-
13-
# Qt-es
14-
15-
/.qmake.cache
1+
/NEncryptionKit.pro.user
2+
/NEncryptionKit/NEncryptionKit.pro.user
163
/.qmake.stash
17-
*.pro.user
18-
*.pro.user.*
19-
*.qbs.user
20-
*.qbs.user.*
21-
*.moc
22-
moc_*.cpp
23-
qrc_*.cpp
24-
ui_*.h
25-
Makefile*
26-
*build-*
27-
28-
# QtCreator
29-
30-
*.autosave
31-
32-
# QtCtreator Qml
33-
*.qmlproject.user
34-
*.qmlproject.user.*
35-
36-
# QtCtreator CMake
37-
CMakeLists.txt.user
38-

Example/.gitignore

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This file is used to ignore files which are generated
2+
# ----------------------------------------------------------------------------
3+
4+
*~
5+
*.autosave
6+
*.a
7+
*.core
8+
*.moc
9+
*.o
10+
*.obj
11+
*.orig
12+
*.rej
13+
*.so
14+
*.so.*
15+
*_pch.h.cpp
16+
*_resource.rc
17+
*.qm
18+
.#*
19+
*.*#
20+
core
21+
!core/
22+
tags
23+
.DS_Store
24+
.directory
25+
*.debug
26+
Makefile*
27+
*.prl
28+
*.app
29+
moc_*.cpp
30+
ui_*.h
31+
qrc_*.cpp
32+
Thumbs.db
33+
*.res
34+
*.rc
35+
/.qmake.cache
36+
/.qmake.stash
37+
38+
# qtcreator generated files
39+
*.pro.user*
40+
41+
# xemacs temporary files
42+
*.flc
43+
44+
# Vim temporary files
45+
.*.swp
46+
47+
# Visual Studio generated files
48+
*.ib_pdb_index
49+
*.idb
50+
*.ilk
51+
*.pdb
52+
*.sln
53+
*.suo
54+
*.vcproj
55+
*vcproj.*.*.user
56+
*.ncb
57+
*.sdf
58+
*.opensdf
59+
*.vcxproj
60+
*vcxproj.*
61+
62+
# MinGW generated files
63+
*.Debug
64+
*.Release
65+
66+
# Python byte code
67+
*.pyc
68+
69+
# Binaries
70+
# --------
71+
*.dll
72+
*.exe
73+

Example/Example.pro

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
QT += core
2+
QT -= gui
3+
4+
CONFIG += c++11
5+
6+
TARGET = NEncryptionKit_Example
7+
CONFIG += console
8+
CONFIG -= app_bundle
9+
10+
TEMPLATE = app
11+
12+
SOURCES += main.cpp
13+
14+
win32{
15+
DESTDIR = $$PWD/../bin
16+
MOC_DIR = $$PWD/build_/moc
17+
RCC_DIR = $$PWD/build_/rcc
18+
OBJECTS_DIR = $$PWD/build_/obj
19+
}
20+
21+
# import dll file
22+
include($$PWD/../NEncryptionKit/NEncryptionKit_inc.pri)

Example/main.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <QCoreApplication>
2+
#include <QFile>
3+
#include <QDebug>
4+
#include "nencryptionkit.h"
5+
6+
int main(int argc, char *argv[])
7+
{
8+
QCoreApplication a(argc, argv);
9+
qDebug()<<"******************************************测试用例开始*****************************************************";
10+
NEncryptionKit test_instance;
11+
qDebug()<<"----------------------------MD5测试开始----------------------------";
12+
QString test_case_001("I am daodaoliang");
13+
QString test_encry_str = test_instance.getMD5Hash(test_case_001);
14+
qDebug()<<"MD5前的字符串:" << test_case_001;
15+
qDebug()<<"MD5后的字符串:" << test_encry_str;
16+
qDebug()<<"----------------------------MD5测试结束----------------------------";
17+
18+
qDebug()<<"----------------------------SHA测试开始----------------------------";
19+
QString test_case_002("I am nami");
20+
QString test_encry_str_002 = test_instance.getSHAHash(test_case_002);
21+
qDebug()<<"SHA前的字符串:" << test_case_002;
22+
qDebug()<<"SHA后的字符串:" << test_encry_str_002;
23+
qDebug()<<"----------------------------SHA测试结束----------------------------";
24+
25+
qDebug()<<"----------------------------Kaiser测试开始-------------------------";
26+
QString test_case_003("I am wangxiaowei");
27+
qint8 test_case_key(7);
28+
QString test_encry_str_003 = test_case_003;
29+
bool ret = test_instance.getByKaiser(test_case_003, test_case_key);
30+
qDebug()<<"加密是否成功:"<<ret;
31+
qDebug()<<"Kaiser前的字符串:" << test_encry_str_003;
32+
qDebug()<<"Kaiser后的字符串:" << test_case_003;
33+
ret = test_instance.getByKaiser(test_case_003, -test_case_key);
34+
qDebug()<<"解密是否成功:"<<ret;
35+
qDebug()<<"解密后的字符串:" << test_case_003;
36+
qDebug()<<"----------------------------Kaiser测试结束-------------------------";
37+
38+
qDebug()<<"----------------------------AES文件测试开始-------------------------";
39+
QString test_case_005("iamdaodaoliang");
40+
string test_case_006;
41+
QString test_case_007;
42+
test_instance.setPassword(QString("IamdaodaoliangSecret"));
43+
ret = test_instance.getEncryByAES(test_case_005,test_case_006);
44+
qDebug()<<"AES加密成功:"<<ret;
45+
qDebug()<<"加密前的数据:"<<test_case_005;
46+
qDebug()<<"加密后的数据:"<<QString::fromStdString(test_case_006);
47+
ret = test_instance.decryptByAES(test_case_006,test_case_007);
48+
qDebug()<<"AES解密成功:"<<ret;
49+
qDebug()<<"解密后的数据:"<<test_case_007;
50+
qDebug()<<"----------------------------AES文件测试结束-------------------------";
51+
52+
qDebug()<<"----------------------------RSA文件测试开始-------------------------";
53+
QString test_case_pub = QCoreApplication::applicationDirPath() + "/daodaoliang_test.pub";
54+
QString test_case_pri = QCoreApplication::applicationDirPath() + "/daodaoliang_test.private";
55+
ret = test_instance.createRSAKey(test_case_pub, test_case_pri);
56+
qDebug()<<"是否产生密钥文件成功:"<<ret;
57+
QByteArray test_encrypt_str;
58+
QString test_decrypt_str;
59+
ret = test_instance.getEncryptByRSA("I am daodaoliang, my daughter is nami", test_encrypt_str, test_case_pub);
60+
qDebug()<<"RSA签名成功:"<<ret;
61+
qDebug()<<"RSA签名后的数据:"<<QString(test_encrypt_str);
62+
ret = test_instance.decryptionByRSA(test_encrypt_str,test_decrypt_str, test_case_pri);
63+
qDebug()<<"RSA解密成功:"<<ret;
64+
qDebug()<<"RSA解密后的数据:"<<test_decrypt_str;
65+
qDebug()<<"----------------------------RSA文件测试结束-------------------------";
66+
67+
qDebug()<<"******************************************测试用例结束*****************************************************";
68+
return a.exec();
69+
}

NEncryptionKit.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
TEMPLATE = subdirs
2+
CONFIG += ordered
3+
SUBDIRS += \
4+
NEncryptionKit \
5+
Example \

0 commit comments

Comments
 (0)