Giter VIP home page Giter VIP logo

qsimplecrypto's Introduction

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-128, AES-192, AES-256

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

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.

qsimplecrypto's People

Contributors

bru74lw1z4rd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

qsimplecrypto's Issues

Wrong type of encryption

Hello,

I found one bug in your code. In function encrypt in QRsa.cpp file you are using PublicDecrypt/PrivateDecrypt instead of PublicEncrypt/PrivateEncrypt. It causes that the condition is never true if someone forwards PublicEncrypt or PrivateEncrypt.

if (type == PublicDecrypt) { result = RSA_public_encrypt(plainText.size(), reinterpret_cast<unsigned char*>(plainText.data()), cipherText.get(), rsa, padding); } else if (type == PrivateDecrypt) { result = RSA_private_encrypt(plainText.size(), reinterpret_cast<unsigned char*>(plainText.data()), cipherText.get(), rsa, padding); }

For Qt6 works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.