All Projects → bricke → Qt Aes

bricke / Qt Aes

Licence: unlicense
Native Qt AES encryption class

Projects that are alternatives of or similar to Qt Aes

Apk Editor Studio
Powerful yet easy to use APK editor for PC and Mac.
Stars: ✭ 197 (-4.83%)
Mutual labels:  qt, qt5
Qhexview
A versatile Hexadecimal widget for Qt5
Stars: ✭ 168 (-18.84%)
Mutual labels:  qt, qt5
Kshare
The free and open source and cross platform screen sharing software.
Stars: ✭ 151 (-27.05%)
Mutual labels:  qt, qt5
Openauto
AndroidAuto headunit emulator
Stars: ✭ 1,926 (+830.43%)
Mutual labels:  qt, qt5
Qmarkdowntextedit
A C++ Qt QPlainTextEdit widget with markdown highlighting support and a lot of other extras
Stars: ✭ 182 (-12.08%)
Mutual labels:  qt, qt5
Sqlitestudio
A free, open source, multi-platform SQLite database manager.
Stars: ✭ 2,337 (+1028.99%)
Mutual labels:  qt, qt5
Shell
🐚 QtQuick and Wayland shell for convergence
Stars: ✭ 168 (-18.84%)
Mutual labels:  qt, qt5
Qdarkstylesheet
A dark style sheet for QtWidgets application
Stars: ✭ 1,952 (+843%)
Mutual labels:  qt, qt5
Qt5.cr
Qt5 bindings for Crystal, based on Bindgen
Stars: ✭ 182 (-12.08%)
Mutual labels:  qt, qt5
Securedefaults
A lightweight wrapper over UserDefaults/NSUserDefaults with an additional layer of AES-256 encryption
Stars: ✭ 179 (-13.53%)
Mutual labels:  aes, aes-encryption
Aescipher Ios
AES encryption working between Objective-C and Java.
Stars: ✭ 198 (-4.35%)
Mutual labels:  aes, aes-encryption
Qml Creative Controls
QML controls for creative applications and creative coding
Stars: ✭ 199 (-3.86%)
Mutual labels:  qt, qt5
Gtkplatform
Run Qt applications using gtk+ as a windowing system.
Stars: ✭ 146 (-29.47%)
Mutual labels:  qt, qt5
Haruna
Open source video player built with Qt/QML and libmpv.
Stars: ✭ 147 (-28.99%)
Mutual labels:  qt, qt5
Moneyguru
Future-aware personal finance application
Stars: ✭ 145 (-29.95%)
Mutual labels:  qt, qt5
Mini Cmake Qt
A minimal CMake template for Qt 5 & 6 projects
Stars: ✭ 156 (-24.64%)
Mutual labels:  qt, qt5
Simple Mail
An SMTP library written in C++ for Qt. Allows applications to send emails (MIME with text, html, attachments, inline files, etc.) via SMTP. Supports SSL and SMTP authentication.
Stars: ✭ 134 (-35.27%)
Mutual labels:  qt, qt5
Qcodeeditor
Qt Code Editor widget.
Stars: ✭ 136 (-34.3%)
Mutual labels:  qt, qt5
Apkstudio
Open-source, cross platform Qt based IDE for reverse-engineering Android application packages.
Stars: ✭ 2,246 (+985.02%)
Mutual labels:  qt, qt5
Browser
🌍 Cross-platform Material design web browser
Stars: ✭ 184 (-11.11%)
Mutual labels:  qt, qt5

Qt-AES

Small and portable AES encryption class for Qt. Native support for all key sizes - 128/192/256 bits - ECB, CBC, CFB and OFB modes AES-NI support for all key sizes - ECB, CBC modes

Usage

Available Methods

// Encode of rawText with key
// iv is used in CBC mode
// return the encrypted byte array
QByteArray encode(const QByteArray rawText, const QByteArray key, const QByteArray iv = QByteArray());

// Decode of rawText with key
// iv is used in CBC mode
// return the decrypted byte array
QByteArray decode(const QByteArray rawText, const QByteArray key, const QByteArray iv = QByteArray());

// Key expansion in Rijndael schedule
// return the new expanded key as byte array
QByteArray expandKey(const QByteArray key);

The same methods are available as static calls

QAESEncryption::Crypt => encode(...)
QAESEncryption::Decrypt => decode(...)
QAESEncryption::ExpandKey => expandKey(...)

AES Levels

The class supports all AES key lenghts

  • 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

Example

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));

AES New Instructions Set

To use the hardware acceleration provided by the AES New Instructions Set, define USE_INTEL_AES_IF_AVAILABLE If the CPU supports it, the code will switch to use AESNI automatically. The feature is enabled by default

Unit Testing

The unit testing vectors used are included in NIST-Recommendation for Block Cipher Modes of Operation

Please note that this code is not audited or AES-certified by any competent authority, use it at your own risk.

Dependencies

  • qtcore

No OpenSSL required.

Contact

Question or suggestions are welcome! Please use the GitHub issue tracking to report suggestions or issues.

License

This software is provided under the UNLICENSE

Known Issues

Please take a look at the list of currently open issues

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].