• Stars
    star
    237
  • Rank 166,179 (Top 4 %)
  • Language
    C++
  • License
    GNU Lesser Genera...
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple encryption library supporting RSA and AES algorithms.

Qt-Secret Logo

Note

The OpenSSL library is better for security and performance, so we implemented a Qt wrapper library to make it easier to use. See the EasySSL library.

Fast encryption library supporting RSA and AES algorithms.

Futures

The Qt-Secret library supports the following algorithms:

RSA

The current implementation supports the following key sizes:

Supported sizes

  • RSA64
  • RSA128
  • RSA256
  • RSA512
  • RSA1024
  • RSA2048
  • RSA3072
  • RSA4096
  • RSA6144
  • RSA8192

Supported futures

  • Encryption and decryption of messages.
  • Signature and verification of the message signature.

AES

AES implementation was borrowed from bricke, because it fulfills the goals of this library.

Individual thanks bricke for implementing the AES encryption class.

AES Levels

The class supports all AES key lengths

  • AES_128
  • AES_192
  • AES_256

Modes

The class supports the following operating modes

  • ECB
  • CBC
  • CFB
  • OFB

Padding

By default the padding method is ISO, however, the class supports:

  • ZERO
  • PKCS7
  • ISO

Build

with qmake

DEFINE+=WITHOUT_GUI fot build without gui example, if you want build gui example remove this line. For build the gui example you need to install qml controls 2 in you os. Try sudo apt install qml-module-qtquick-controls2 qtdeclarative5-dev qtdeclarative5-qtquick2-plugin

  • make -j8
  • make test #(for testing)

with cmake

Include

for qmake projects

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
  • git submodule update --init --recursive
  • Add to the list of libraries for the Qt-Secret assembly. For example, you can create Main.Pro in which connect Qt-Secret and your project.pro files as subprojects.

Main.pro:

TEMPLATE = subdirs
CONFIG += ordered

SUBDIRS += \
           Qt-Secret \
           MyProject
  • Include in your MyProject.pro file the pri file of Qt-Secret library
include($$PWD/../Qt-Secret/src/Qt-Secret.pri)
  • Rebuild your project

For cmake projects

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
  • git submodule update --init --recursive
  • Include in your CMakeLists.txt file the main CMakeLists.txt file of Qt-Secret library
  add_subdirectory(Qt-Secret)
  target_link_libraries(MyBinary PUBLIC Qt-Secret)
  • Rebuild your project

Note

By Default Qt-Secret makes as a static library. If you want to create a shared library just add the BUILD_SHARED_LIBS into your main CMakeLists.txt file. Example :

set(BUILD_SHARED_LIBS ON)
add_subdirectory(Qt-Secret)
target_link_libraries(MyBinary PUBLIC Qt-Secret)

For other build systems

  • cd yourRepo
  • git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
  • git submodule update --init --recursive
  • Add the rule for build Qt-Secret
  • Add INCLUDEPATH and LIBS for your build system
  • Rebuild your project

Detailed instructions of include in QtCreator see here.

Usage

RSA

Encryption and decryption of messages.

#include <qrsaencryption.h>
#include <QDebug>

bool testEncryptAndDecryptExample() {

    QByteArray pub, priv;
    QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);
    e.generatePairKey(pub, priv); // or other rsa size

    QByteArray msg = "test message";

    auto encryptMessage = e.encode(msg, pub);

    if (encryptMessage == msg)
        return false;

    auto decodeMessage = e.decode(encryptMessage, priv);

    return decodeMessage == msg;
}

int main() {
    if (testEncryptAndDecryptExample()) {
        qInfo() << "Success!";
    }
}

Signature and verification of the message signature.

#include <qrsaencryption.h>
#include <QDebug>

bool testExample() {
    QByteArray pub, priv;
    QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);
    e.generatePairKey(pub, priv); // or other rsa size

    QByteArray msg = "test message";

    auto signedMessage = e.signMessage(msg, priv);

    if (e.checkSignMessage(signedMessage, pub)) {
        qInfo() <<" message signed success";
        return true;
    }

    return false;

}

int main() {
    if (testExample()) {
        qInfo() <<"success!";
    }
}

AES

Sample code using a 128bit key in ECB mode

#include "qaesencryption.h"

QAESEncryption encryption(QAESEncryption::AES_128, QAESEncryption::ECB);
QByteArray encodedText = encryption.encode(plainText, key);

QByteArray decodedText = encryption.decode(encodedText, key);

Example for 256bit CBC using QString

#include <QCryptographicHash>
#include "qaesencryption.h"

QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::CBC);

QString inputStr("The Advanced Encryption Standard (AES), also known by its original name Rijndael "
                 "is a specification for the encryption of electronic data established by the U.S. "
                "National Institute of Standards and Technology (NIST) in 2001");
QString key("your-string-key");
QString iv("your-IV-vector");

QByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256);
QByteArray hashIV = QCryptographicHash::hash(iv.toLocal8Bit(), QCryptographicHash::Md5);

QByteArray encodeText = encryption.encode(inputStr.toLocal8Bit(), hashKey, hashIV);
QByteArray decodeText = encryption.decode(encodeText, hashKey, hashIV);

QString decodedString = QString(encryption.removePadding(decodeText));

//decodedString == inputStr !!! 

Example via static invocation

Static invocation without creating instances, 256 bit key, ECB mode, starting from QString text/key

#include <QCryptographicHash>
#include "qaesencryption.h"

QString inputStr("The Advanced Encryption Standard (AES), also known by its original name Rijndael "
                 "is a specification for the encryption of electronic data established by the U.S. "
                "National Institute of Standards and Technology (NIST) in 2001");
QString key("your-string-key");
QString iv("your-IV-vector");

QByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256);
QByteArray hashIV = QCryptographicHash::hash(iv.toLocal8Bit(), QCryptographicHash::Md5);

//Static invocation
QByteArray encrypted = QAESEncryption::Crypt(QAESEncryption::AES_256, QAESEncryption::CBC, 
                        inputStr.toLocal8Bit(), hashKey, hashIV);
//...
// Removal of Padding via Static function
QString decodedString = QString(QAESEncryption::RemovePadding(decodeText));

More Repositories

1

CQtDeployer

This project is used to deploy applications written using QML, qt or other ะก / ะก++ frameworks.
C++
540
star
2

QMLLoginView

Simple login window library for qml projects.
C++
16
star
3

sdkmanager-android

Wraper of android sdk manager for snap store
Shell
16
star
4

QStyleSheet

StyleSheet for qt apps
CSS
16
star
5

Hanoi-Towers

Hanoi Towers Game
C++
13
star
6

SimpleQmlNotify

Simple Qml notification service for qml applications.
C++
13
star
7

SoundBand

Mobile and desktop song sync audio player. working on wifi.
C++
11
star
8

CMake

Cmake modules for quasarapp projects
CMake
6
star
9

CheatCard

CheatCard - This is service which provides the ability to conveniently create discount cards for the clients of your business.
C++
5
star
10

openssl-builder

This is build scripts for open ssl
Shell
4
star
11

Crawl

Cool game
C++
4
star
12

CMakeProject

Template repository for cmake project
CMake
4
star
13

QtDeployer

qt Deployer
C++
4
star
14

QuasarAppCI

buildBot server of quasarapp
Python
4
star
15

Patronum

This is extension libraries for control your daemons.
C++
4
star
16

QuasarAppLib

global function for quasar app
C++
4
star
17

Heart

QuasarApp Heart - it is base backend for C++/Qt projects. This library support work with databases and work with lite network requests.
C++
4
star
18

CopyrightFixer

Console application for updating copyright in code
C++
3
star
19

site-server

JavaScript
2
star
20

DoxyStyle

Style for Documentation of QuasarApp
CSS
2
star
21

easyssl

This is Qt wrapper of the ssl library.
C++
2
star
22

Credits

This is Credits page of QuasarApp projects.
QML
2
star
23

site-client

JavaScript
2
star
24

ViewSolutions

View solutions of qml for quasarapp projects
QML
1
star
25

CQtDeployerServer

This is temp project for adding support the generate online repositories.
C++
1
star
26

Guidelines

Guidelines of Development in QuasarApp
1
star
27

QtDeployTemplate

buildet qt dependense
QMake
1
star
28

QuasarAppScripts

Work scripts for QuasarApp projects
Shell
1
star
29

QtNativeTr

This is library that contains all native qt translation files
C++
1
star
30

QrCodes

C++
1
star
31

qTbot

C++
1
star
32

Platforms

Platforms utils of quasarapp
C++
1
star
33

DesktopInstaller

Desktop Installer of QuasaApp projects
QMake
1
star
34

site

1
star
35

DocsSite

C++
1
star
36

TelegramDeliveryBot

1
star
37

Job

This project contains internal vacancies of the QuasarApp group.
1
star
38

SecretService

Simple service to save your own secrets strings, and provide fast access by hashes IDs.
C++
1
star
39

DoctorPill

This is simple library for create productions fixes for your applications.
C++
1
star