Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. best way to use AES Encryption in QT
Forum Updated to NodeBB v4.3 + New Features

best way to use AES Encryption in QT

Scheduled Pinned Locked Moved Solved General and Desktop
26 Posts 2 Posters 5.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saeid0034
    wrote on last edited by
    #1

    hi sorry if this question is bad or i post it on wrong forum

    i need to use AES-256/CBC Encryption for one of my project
    first i try to use Botan lib for doing this job (i follow This tutorial) but sadly after fully write the code i get this error

    cannot find -lbotand
    collect2.exe: error: id returned 1 exit status
    

    i dont know i get this error for what (also i cant find any good information about this error in internet)
    i also use Qt-AES but its give me lots of error too
    75a6b24d-4e89-41ae-adef-c6289182d290-image.png
    anyone can help me to find a good way for use AES-256/CBC Encryption for Encrypt String in QT?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you install the botan development package ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Did you install the botan development package ?

        S Offline
        S Offline
        saeid0034
        wrote on last edited by
        #3

        @SGaist said in best way to use AES Encryption in QT:

        Hi,

        Did you install the botan development package ?

        thanks for reply
        i only build botan from source code (with nmake)
        can you tell me where i can get botan development package

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Nothing wrong with using your own self built version.
          Where did you install the library ?
          Do you have the library file ending with a d ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          1
          • SGaistS SGaist

            Nothing wrong with using your own self built version.
            Where did you install the library ?
            Do you have the library file ending with a d ?

            S Offline
            S Offline
            saeid0034
            wrote on last edited by saeid0034
            #5

            @SGaist said in best way to use AES Encryption in QT:

            Nothing wrong with using your own self built version.
            Where did you install the library ?
            Do you have the library file ending with a d ?

            i only have botan.lib in C:\Botan\lib
            and i cant find library file ending with a d
            I also build botan based of guide in https://botan.randombit.net/handbook/building.html

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then you should link to botan and not botand.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply
              1
              • SGaistS SGaist

                Then you should link to botan and not botand.

                S Offline
                S Offline
                saeid0034
                wrote on last edited by saeid0034
                #7

                @SGaist said in best way to use AES Encryption in QT:

                Then you should link to botan and not botand.

                win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../Botan/lib/ -lbotan
                else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../Botan/lib/ -lbotand
                
                INCLUDEPATH += $$PWD/../../../../../Botan/include
                DEPENDPATH += $$PWD/../../../../../Botan/include
                

                when i add lib on qt this line add in pro file
                also when i delete else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../Botan/lib/ -lbotand i got more error
                everything seems good until i try to compile

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Either you need to also build botan in debug mode so you have the two versions of the library or you change the .pro file to always link to the version you have built.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  S 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    Either you need to also build botan in debug mode so you have the two versions of the library or you change the .pro file to always link to the version you have built.

                    S Offline
                    S Offline
                    saeid0034
                    wrote on last edited by
                    #9

                    @SGaist said in best way to use AES Encryption in QT:

                    Either you need to also build botan in debug mode so you have the two versions of the library or you change the .pro file to always link to the version you have built.

                    when i edit pro file and remove other one its give me more error
                    how can i build debug version of botan?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Because you removed the line trying to link to botand -and you likely have now a lot of undefined symbols.

                      Just use:

                      LIBS += -L$$PWD/../../../../../Botan/lib/ -lbotan
                      

                      As for building botan in debug mode, tell cmake you want a Debug build.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      S 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        Because you removed the line trying to link to botand -and you likely have now a lot of undefined symbols.

                        Just use:

                        LIBS += -L$$PWD/../../../../../Botan/lib/ -lbotan
                        

                        As for building botan in debug mode, tell cmake you want a Debug build.

                        S Offline
                        S Offline
                        saeid0034
                        wrote on last edited by
                        #11

                        @SGaist said in best way to use AES Encryption in QT:

                        LIBS += -L$$PWD/../../../../../Botan/lib/ -lbotan

                        I test what you say
                        this time i get even more error
                        daee337d-86c0-4550-900c-99709a307500-image.png

                        my .pro

                        LIBS += -L$$PWD/../../../../../Botan/lib/ -lbotan
                        
                        INCLUDEPATH += $$PWD/../../../../../Botan/include
                        DEPENDPATH += $$PWD/../../../../../Botan/include
                        

                        my full code:

                        #include "mainwindow2.h"
                        #include "ui_mainwindow2.h"
                        #include "botan/botan.h"
                        #include "botan/pipe.h"
                        #include "botan/aes.h"
                        #include "botan/filters.h"
                        
                        MainWindow2::MainWindow2(QWidget *parent) :
                            QMainWindow(parent),
                            ui(new Ui::MainWindow2)
                        {
                            ui->setupUi(this);
                            Botan::InitializationVector init;
                        }
                        
                        MainWindow2::~MainWindow2()
                        {
                            delete ui;
                        }
                        
                        void MainWindow2::on_pushButton_clicked()
                        {
                            Botan::AutoSeeded_RNG rng;
                            Botan::SymmetricKey key(rng,32);
                            Botan::InitializationVector IV(rng,16);
                            Botan::Pipe pipe(Botan::get_cipher("AES-256/CBC",key,IV,Botan::ENCRYPTION),new Botan::Hex_Encoder);
                            pipe.process_msg(ui->textEdit_input->toPlainText().toStdString());
                            std::string m1=pipe.read_all_as_string(0);
                            ui->textEdit_output_E->setText(QString::fromStdString(m1));
                        }
                        
                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Are you sure that the library was built for thé same architecture as the Qt version you are using ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          S 1 Reply Last reply
                          1
                          • SGaistS SGaist

                            Are you sure that the library was built for thé same architecture as the Qt version you are using ?

                            S Offline
                            S Offline
                            saeid0034
                            wrote on last edited by
                            #13

                            @SGaist said in best way to use AES Encryption in QT:

                            Are you sure that the library was built for thé same architecture as the Qt version you are using ?

                            i see a video in yotube use botan 1.10.8 on QT 4.8.5
                            you think its not support new verson of qt?

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              You should use the latest version of botan for security reasons.

                              In any case, it's completely unrelated to my question: aare the architectures of your botan build and Qt the same ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              S 1 Reply Last reply
                              1
                              • SGaistS SGaist

                                You should use the latest version of botan for security reasons.

                                In any case, it's completely unrelated to my question: aare the architectures of your botan build and Qt the same ?

                                S Offline
                                S Offline
                                saeid0034
                                wrote on last edited by
                                #15

                                @SGaist said in best way to use AES Encryption in QT:

                                You should use the latest version of botan for security reasons.

                                In any case, it's completely unrelated to my question: aare the architectures of your botan build and Qt the same ?

                                sorry for this question, but how i cant found out (im new at c++ and qt)

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  You can use dumpbin as explained here

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  S 1 Reply Last reply
                                  1
                                  • SGaistS SGaist

                                    You can use dumpbin as explained here

                                    S Offline
                                    S Offline
                                    saeid0034
                                    wrote on last edited by
                                    #17

                                    @SGaist said in best way to use AES Encryption in QT:

                                    You can use dumpbin as explained here

                                    i check botan-ci.exe, here is result
                                    e8213711-4ce1-4e40-a676-2d89e29f19f5-image.png

                                    and here is botan.dll
                                    7b54fc57-5a87-4b33-b861-4b0a32690381-image.png

                                    both is 64bit
                                    and also my qt compiler is 64bit too
                                    d85889d1-235a-4df2-8a2b-ef3ab53d669a-image.png

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      Did you also compile botan with MinGW ?

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      S 1 Reply Last reply
                                      1
                                      • SGaistS SGaist

                                        Did you also compile botan with MinGW ?

                                        S Offline
                                        S Offline
                                        saeid0034
                                        wrote on last edited by
                                        #19

                                        @SGaist said in best way to use AES Encryption in QT:

                                        Did you also compile botan with MinGW ?

                                        no i compile it with nmake
                                        i need to compile it with MiniGW?

                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          If you used nmake, it means that in fact you used Visual Studio to build botan. So there's your issue. You can't mix C++ code built with MinGW with C++ code built with Visual Studio.

                                          Tow options here:

                                          • rebuild botan using MinGW
                                          • change your Qt version and use the one that matches your Visual Studio version

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          S 1 Reply Last reply
                                          2

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved