{"id":21023443,"url":"https://github.com/quasarapp/qt-secret","last_synced_at":"2025-04-07T07:12:31.162Z","repository":{"id":36074740,"uuid":"189167143","full_name":"QuasarApp/Qt-Secret","owner":"QuasarApp","description":"Simple encryption library supporting RSA and AES algorithms.","archived":false,"fork":false,"pushed_at":"2023-03-26T19:34:05.000Z","size":6063,"stargazers_count":256,"open_issues_count":0,"forks_count":70,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-03-31T06:01:47.706Z","etag":null,"topics":["aes","alghorithm","algorithms","cmake","cqtdeployer","cryptography","library","qmake","qt","quasarapp","rsa"],"latest_commit_sha":null,"homepage":"https://quasarapp.ddns.net:3031/docs/QuasarApp/Qt-Secret/latest/index.html","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QuasarApp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"QuasarApp"}},"created_at":"2019-05-29T06:50:04.000Z","updated_at":"2025-03-11T04:36:12.000Z","dependencies_parsed_at":"2025-01-15T14:19:33.625Z","dependency_job_id":"e0382752-5462-4f1f-b5d9-79bb81baeca4","html_url":"https://github.com/QuasarApp/Qt-Secret","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuasarApp%2FQt-Secret","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuasarApp%2FQt-Secret/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuasarApp%2FQt-Secret/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuasarApp%2FQt-Secret/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QuasarApp","download_url":"https://codeload.github.com/QuasarApp/Qt-Secret/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247608153,"owners_count":20965952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aes","alghorithm","algorithms","cmake","cqtdeployer","cryptography","library","qmake","qt","quasarapp","rsa"],"created_at":"2024-11-19T11:18:11.067Z","updated_at":"2025-04-07T07:12:31.142Z","avatar_url":"https://github.com/QuasarApp.png","language":"C++","funding_links":["https://patreon.com/QuasarApp"],"categories":[],"sub_categories":[],"readme":"# ![Qt-Secret Logo](res/png/Qt-Secret_Banner_web.png)\n\n# Note \nThe OpenSSL library is better for security and performance, so we implemented a Qt wrapper library to make it easier to use. See the [EasySSL](https://github.com/QuasarApp/easyssl) library.\n\nFast encryption library supporting RSA and AES algorithms.\n\n# Futures \nThe Qt-Secret library supports the following algorithms:\n\n### RSA\nThe current implementation supports the following key sizes:\n#### Supported sizes\n * RSA64 \n * RSA128 \n * RSA256\n * RSA512\n * RSA1024 \n * RSA2048\n * RSA3072\n * RSA4096\n * RSA6144\n * RSA8192 \n\n#### Supported futures \n\n* Encryption and decryption of messages.\n* Signature and verification of the message signature.\n\n### AES\nAES implementation was borrowed from [bricke](https://github.com/bricke/Qt-AES), because it fulfills the goals of this library.\n\nIndividual thanks [bricke](https://github.com/bricke) for implementing the AES encryption class.\n\n#### AES Levels\nThe class supports all AES key lengths\n\n* AES_128\n* AES_192\n* AES_256\n\n#### Modes\nThe class supports the following operating modes\n\n* ECB\n* CBC\n* CFB\n* OFB\n\n#### Padding\nBy default the padding method is `ISO`, however, the class supports:\n\n* ZERO\n* PKCS7\n* ISO\n\n\n# Build\n\n## with qmake \n\n * git clone https://github.com/QuasarApp/Qt-Secret.git\n * cd Qt-Secret\n * git submodule update --init --recursive\n * sudo apt install qt5-default\n * qmake -r DEFINE+=WITHOUT_GUI Qt-Secret.pro \n  \u003e 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**\n * make -j8\n * make test #(for testing)\n\n## with cmake \n\n * git clone https://github.com/QuasarApp/Qt-Secret.git\n * cd Qt-Secret\n * git submodule update --init --recursive\n * sudo apt install qt5-default\n * cmake -DCMAKE_PREFIX_PATH=you/Qt/dir .\n * make -j8\n * make test #(for testing)\n\n# Include\n\n## for qmake projects \n\n * cd yourRepo\n * git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule\n * git submodule update --init --recursive\n * 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.\n \n **Main.pro:**\n``` qmake\nTEMPLATE = subdirs\nCONFIG += ordered\n\nSUBDIRS += \\\n           Qt-Secret \\\n           MyProject\n```\n * Include in your MyProject.pro file the pri file of Qt-Secret library\n ``` qmake\n include($$PWD/../Qt-Secret/src/Qt-Secret.pri)\n ```\n * Rebuild your project\n\n### For cmake projects\n \n * cd yourRepo\n * git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule\n * git submodule update --init --recursive\n * Include in your CMakeLists.txt file the main CMakeLists.txt file of Qt-Secret library\n  ``` cmake\n    add_subdirectory(Qt-Secret)\n    target_link_libraries(MyBinary PUBLIC Qt-Secret)\n  ```\n * Rebuild your project\n \n#### Note\n\nBy 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 :\n\n```cmake\nset(BUILD_SHARED_LIBS ON)\nadd_subdirectory(Qt-Secret)\ntarget_link_libraries(MyBinary PUBLIC Qt-Secret)\n```\n\n## For other build systems\n \n * cd yourRepo\n * git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule\n * git submodule update --init --recursive\n * Add the rule for build Qt-Secret\n * Add INCLUDEPATH and LIBS for your build system \n * Rebuild your project\n\n\n#### Detailed instructions of include in QtCreator see [here](Doc/QtCreator.md).\n\n# Usage\n\n## RSA\n\n### Encryption and decryption of messages.\n\n``` cpp\n#include \u003cqrsaencryption.h\u003e\n#include \u003cQDebug\u003e\n\nbool testEncryptAndDecryptExample() {\n\n    QByteArray pub, priv;\n    QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);\n    e.generatePairKey(pub, priv); // or other rsa size\n\n    QByteArray msg = \"test message\";\n\n    auto encryptMessage = e.encode(msg, pub);\n\n    if (encryptMessage == msg)\n        return false;\n\n    auto decodeMessage = e.decode(encryptMessage, priv);\n\n    return decodeMessage == msg;\n}\n\nint main() {\n    if (testEncryptAndDecryptExample()) {\n        qInfo() \u003c\u003c \"Success!\";\n    }\n}\n```\n\n### Signature and verification of the message signature.\n\n``` cpp\n#include \u003cqrsaencryption.h\u003e\n#include \u003cQDebug\u003e\n\nbool testExample() {\n    QByteArray pub, priv;\n    QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);\n    e.generatePairKey(pub, priv); // or other rsa size\n\n    QByteArray msg = \"test message\";\n\n    auto signedMessage = e.signMessage(msg, priv);\n\n    if (e.checkSignMessage(signedMessage, pub)) {\n        qInfo() \u003c\u003c\" message signed success\";\n        return true;\n    }\n\n    return false;\n\n}\n\nint main() {\n    if (testExample()) {\n        qInfo() \u003c\u003c\"success!\";\n    }\n}\n```\n\n## AES\n\nSample code using a 128bit key in ECB mode\n``` cpp\n#include \"qaesencryption.h\"\n\nQAESEncryption encryption(QAESEncryption::AES_128, QAESEncryption::ECB);\nQByteArray encodedText = encryption.encode(plainText, key);\n\nQByteArray decodedText = encryption.decode(encodedText, key);\n```\n\nExample for 256bit CBC using QString\n``` cpp\n#include \u003cQCryptographicHash\u003e\n#include \"qaesencryption.h\"\n\nQAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::CBC);\n\nQString inputStr(\"The Advanced Encryption Standard (AES), also known by its original name Rijndael \"\n                 \"is a specification for the encryption of electronic data established by the U.S. \"\n                \"National Institute of Standards and Technology (NIST) in 2001\");\nQString key(\"your-string-key\");\nQString iv(\"your-IV-vector\");\n\nQByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256);\nQByteArray hashIV = QCryptographicHash::hash(iv.toLocal8Bit(), QCryptographicHash::Md5);\n\nQByteArray encodeText = encryption.encode(inputStr.toLocal8Bit(), hashKey, hashIV);\nQByteArray decodeText = encryption.decode(encodeText, hashKey, hashIV);\n\nQString decodedString = QString(encryption.removePadding(decodeText));\n\n//decodedString == inputStr !!! \n```\n\n### Example via static invocation\nStatic invocation without creating instances, 256 bit key, ECB mode, starting from *QString* text/key\n``` cpp\n#include \u003cQCryptographicHash\u003e\n#include \"qaesencryption.h\"\n\nQString inputStr(\"The Advanced Encryption Standard (AES), also known by its original name Rijndael \"\n                 \"is a specification for the encryption of electronic data established by the U.S. \"\n                \"National Institute of Standards and Technology (NIST) in 2001\");\nQString key(\"your-string-key\");\nQString iv(\"your-IV-vector\");\n\nQByteArray hashKey = QCryptographicHash::hash(key.toLocal8Bit(), QCryptographicHash::Sha256);\nQByteArray hashIV = QCryptographicHash::hash(iv.toLocal8Bit(), QCryptographicHash::Md5);\n\n//Static invocation\nQByteArray encrypted = QAESEncryption::Crypt(QAESEncryption::AES_256, QAESEncryption::CBC, \n                        inputStr.toLocal8Bit(), hashKey, hashIV);\n//...\n// Removal of Padding via Static function\nQString decodedString = QString(QAESEncryption::RemovePadding(decodeText));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasarapp%2Fqt-secret","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquasarapp%2Fqt-secret","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasarapp%2Fqt-secret/lists"}