QSimpleCrypto
QSimpleCrypto copied to clipboard
Small C++ cryptography library based on Qt and OpenSSL.
QSimpleCrypto
Small C++ cryptographic library based on Qt and OpenSSL.
This library also working with Android.
Dependencies
This library requires no special dependencies except of Qt with the OpenSSL (version 1.1.1 or later).
AES Block Sizes
AES Ciphers
- Electronic codebook (ECB)
- Cipher block chaining (CBC)
- Cipher feedback (CFB)
- Output Feedback (OFB)
- Counter Mode (CTR)
- Galois/Counter Mode (GCM)
- Counter with Cipher Block Chaining-Message Authentication Code (CCM)
Cryptosystems
- RSA (Rivest–Shamir–Adleman)
Certificates
Build
Before building lib, you have to add OpenSSL lib to root folder or change path in .pro file.
cd <projectDirecoty>
qmake QSimpleCrypto.pro
make
How to use
To get started, you need to add OpenSSL library to your project.
You can download OpenSSL on:
- Qt Maintenance Tool (downloaded files will be in Qt/Tools/ folder)
- OpenSSL site.
After building library and linking OpenSSL, you need to link QSimpleCrypto to your project.
Example:
#include <QDebug>
#include <QByteArray>
#include "QAEAD.h"
int main() {
QByteArray key = "AABBCCEEFFGGHHKKLLMMNNOOPPRRSSTT";
QByteArray iv = "AABBCCEEFFGGHHKKLLMMNNOOPPRRSSTT";
QByteArray aad = "AABBCCDDEEFF";
QByteArray tag = "AABBCCDDEEFF";
QSimpleCrypto::QAead aead;
QByteArray encrypted = aead.encryptAesGcm("Hello World", key, iv, &tag, aad);
QByteArray decrypted = aead.decryptAesGcm(bytes, key, iv, &tag, aad);
}
Note: encryption and decryption functions returns value in hex dimension. So, if you want to display encrypted or decrypted value you should convert or deconvert received value.
More information you can find on wiki.