Data encryption by RSA algorithm in Qt with public and private keys without binding to OpenSSL

RSA, Qt, шифрование в qt, private key, asynchronous encryption, ge, публичный и приватные ключи, AES, cryptography, crypto, QuasarApp, Public key, Qt-Sekret

Introduction

In this article there is a way how to organize message encryption, as well as use RSA (public and private keys) algorithms without libraries similar to OpenSSL, QCA or LibSodium.

How does it work?

Why is it necessary?

There are many encryption algorithms, most of them are based on an idea that in a message you've got there is a key to encrypt your message and send it to the recipient. It is assumed that the recipient has already got the encryption key so the recipient can decrypt it. However this method isn't usable in any case , because the encryption key should somehow sent the way nobody can intercept it,but this is almost impossible.

That's why nowadays the RSA encryption method using public and private key (asynchronous encryption) has become the most reliable and popular.

The working principle is the following:
As an example, we use the already established names of encryption participants: Alice and Bob.
Suppose Alice wants to send Bob a secret message, but doesn't want anyone else to see it.

  • Bob creates two keys for this operation: public and private.

  • Bob sends the public key to Alice.

  • Alice encrypts the message with the Bob’s public key.

  • Alice sends the encrypted message to Bob.

  • Bob decrypts Alice's message with a private key.

Eve, who wants to find out what Alice and Bob correspond with, intercepts all their messages. She cannot do anything with them, because she hasn't got their private keys, since in the RSA algorithm the encrypted message with key A (public key) can be decrypted only by its A1 pair (private key).
Thus, you can easily and conveniently protect the important information.

Description.

Qt-Secret is a simple library created by the QuasarApp group on Qt / qmake, the goal is to provide Basic encryption opportunities, which lack in the native Qt. Namely: RSA and AES algorithms.

Key features:

  • Generation of RSA64 and RSA128 key pairs (it is supposed to support quantity of numbers up to RSA2048)
  • Encryption and Decryption RSA.
  • Signature and message authentication.
  • AES key generation (AES64, AES128, AES256)
  • Encryption and Decryption AES

Working with Qt-Secret

Build the library and add it in a project using qmake

  • Open your repository
    cd yourRepo
  • Add Qt-Secret in your repository, for example, a submodule
    The git add submodule https://github.com/QuasarApp/Qt-Secret.git
  • Update your submodules

    git submodule update --init --recursive

  • Add your "pri" Qt-Secret library file in your "pro" file.

    include ($$PWD/Qt-Secret/src/Qt-Secret.pri)

  • Rebuild the project

The library is added in your project, now you can use it.

An example of using

Encrypting and decrypting messages.
#include <qrsaencryption.h> // Include the Qt-Secret library (RSA)

QByteArray pub, priv; // Create variables to keys.
QRSAEncryption e; // Create a variable to cryptographer

// Generate a pair of keys with a bit depth of 128
e.generatePairKey (pub, priv, QRSAEncryption :: Rsa :: RSA_128); // or QRSAEncryption :: Rsa :: RSA_64
QByteArray msg = "test message";


auto encodeData = e.encode (msg, pub); // encrypt the message with the public key
auto decodeData = e.decode (encodeData, priv); // decrypt with the private key

qDebug () << decodeData; // check in the message.



Signature and verification of message signature.
#include <qrsaencryption.h>

// Initialization
QByteArray pub, priv;
QRSAEncryption e;
e.generatePairKey (pub, priv, QRSAEncryption :: Rsa :: RSA_128); // or QRSAEncryption :: Rsa :: RSA_64

QByteArray msg = "test message";

auto signatureMessage = e.signMessage (msg, priv); // sign the message

if (e.checkSignMessage (signatureMessage, pub)) {// check the signature
// message signed successfully
}

Conclusion

This library is a good solution for simple encryption tasks.

  • easy to include;
  • easy to use.

It's good to use a pair of keys for one working session.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.
- company blog

Comments

Only authorized users can post comments.
Please, Log in or Sign up
Looking for a Job?
25,000.00 руб. - 30,000.00 руб.
Разработчик Qt/C++
Barnaul, Altai Krai, Russia

For registered users on the site there is a minimum amount of advertising

DSh
Sept. 21, 2019, 2:55 p.m.
Dmitrij Shilkov

C++ - Test 001. The first program and data types

  • Result:46points,
  • Rating points-6
s
Sept. 18, 2019, 5:19 p.m.
sanyalitv

C++ - Test 002. Constants

  • Result:33points,
  • Rating points-10
s
Sept. 18, 2019, 5:12 p.m.
sanyalitv

C++ - Test 001. The first program and data types

  • Result:80points,
  • Rating points4
Last comments
M
Sept. 20, 2019, 11:25 a.m.
Mark

вызываю метод get у m_downloader в другом методе и приложение начинает вылетать. В чем ошибка?
M
Sept. 19, 2019, 5:45 a.m.
Mark

А вот как выгрузить файл на сервер по http протоколу? Допустим на regRu. И как получить путь файла, которой отображается в файловом менеджере regRu, чтобы загрузить его.
Sept. 17, 2019, 6:07 a.m.
Misha Lebedev

Кстати интересные темы нашёл тут https://emacsway.github.io/ru/django-framework/#django-models Может что полезного тоже Евгений найдёте
Sept. 17, 2019, 4:50 a.m.
Misha Lebedev

Доброго времени суток. Спасибо за хороший ответ, У меня ситуация така что в галлереи будет несколько миллионов фотографий с фильтрами и тегами , и я опасаюсь за производительност . Это ос…
Sept. 17, 2019, 3:23 a.m.
Evgenij Legotskoj

Добрый день. Да, я тоже читал ту статью в своё время и согласен с тем, что внешние ключи гораздо лучше, чем GenericForeignKey. Выборки в ряде случае работают быстрее. Но лично мне про…
Now discuss on the forum
M
Sept. 22, 2019, 1:54 a.m.
Mark

Пока реализовал так: на сервере лежат сами файлы и файл с именами всех файлов и их версий, который админ обновляет при довавлении файла. Клиентское по парсит этот файл и таким образом понимает к…
MS
Sept. 21, 2019, 12:51 p.m.
Mihail Sermjazhko

Так работает import QtQuick 2.7import QtQuick.Window 2.2import QtQuick.Controls 2.0Window { id: demo width: 800 height: 600 visible: true color: "#ff303030" prope…
MS
Sept. 21, 2019, 11:46 a.m.
Mihail Sermjazhko

Говорят через делегат должно работать: ListView{ id:l anchors.fill: parent model: ["data 1","data 2","data 3"] currentIndex : 2 delegate: Text { Rectangle{ …
C
Sept. 21, 2019, 9:08 a.m.
Cobra91151

Здравствуйте! Я хочу подключатся к сетям WiFi Enterprise через свою программу. Настроил Radius Server, поключение к сети через Windows работает. Но при подключении через программу пишет: о…
Sept. 20, 2019, 4:56 a.m.
Pavel K.

Привет , подскажите кто-нибудь , как сделать драг н дроп , не нарушая при этом логику работы зума? import QtQuick 2.6 import QtGraphicalEffects 1.0 Page { id:win property string fi…
EVILEG
About
Services
© EVILEG 2015-2019
Recommend hosting TIMEWEB