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. Importing JAVA libraries in QT
Forum Update on Monday, May 27th 2025

Importing JAVA libraries in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 939 Views
  • 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.
  • C Offline
    C Offline
    cnag
    wrote on 12 Mar 2021, 11:35 last edited by
    #1

    I have the following java implemented for signature generation(private and public keys) and encryption.
    How to import java libraries in QT or Is there any libraries in QT which can be used for signature generation and encryption?
    can anyone guide me through here!!!

    import java.security.KeyFactory;
    import java.security.Signature;
    import java.security.spec.PKCS8EncodedKeySpec;
    import java.util.Base64;
    public class DigitalSignatureClient {
    public static void main(String[] args) throws Exception {
    String jsonPayload = "{"Colour": Green,"Quantity": "350","Origin": "India", "cat_ID": "00498D4AC","Member_Id": "XYZ","Availablity": "yes","Business-cat": "Food"}";
    String strPrivateKey = "xyz";
    String realPK = strPrivateKey.replaceAll(", ", "")

    	byte[] b1 = Base64.getDecoder().decode(realPK);
    	PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(b1);
    	KeyFactory kf = KeyFactory.getInstance("RSA");
    	Signature privateSignature = Signature.getInstance("SHA256withRSA");
    	privateSignature.initSign(kf.generatePrivate(spec));
    	privateSignature.update(jsonPayload.getBytes("UTF-8"));
    	byte[] s = privateSignature.sign();
    	String base64Signature = Base64.getEncoder().encodeToString(s);
    	System.out.println("Signature=\n" + base64Signature);
    }
    

    }

    Thanks in advance

    J 1 Reply Last reply 12 Mar 2021, 12:01
    0
    • C cnag
      12 Mar 2021, 11:35

      I have the following java implemented for signature generation(private and public keys) and encryption.
      How to import java libraries in QT or Is there any libraries in QT which can be used for signature generation and encryption?
      can anyone guide me through here!!!

      import java.security.KeyFactory;
      import java.security.Signature;
      import java.security.spec.PKCS8EncodedKeySpec;
      import java.util.Base64;
      public class DigitalSignatureClient {
      public static void main(String[] args) throws Exception {
      String jsonPayload = "{"Colour": Green,"Quantity": "350","Origin": "India", "cat_ID": "00498D4AC","Member_Id": "XYZ","Availablity": "yes","Business-cat": "Food"}";
      String strPrivateKey = "xyz";
      String realPK = strPrivateKey.replaceAll(", ", "")

      	byte[] b1 = Base64.getDecoder().decode(realPK);
      	PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(b1);
      	KeyFactory kf = KeyFactory.getInstance("RSA");
      	Signature privateSignature = Signature.getInstance("SHA256withRSA");
      	privateSignature.initSign(kf.generatePrivate(spec));
      	privateSignature.update(jsonPayload.getBytes("UTF-8"));
      	byte[] s = privateSignature.sign();
      	String base64Signature = Base64.getEncoder().encodeToString(s);
      	System.out.println("Signature=\n" + base64Signature);
      }
      

      }

      Thanks in advance

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 12 Mar 2021, 12:01 last edited by
      #2

      @cnag said in Importing JAVA libraries in QT:

      How to import java libraries in QT

      Qt is a C++ framework.
      What you want is to know how to execute Java binaries in a C++ application. See https://docs.oracle.com/javase/8/docs/technotes/guides/jni/

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cnag
        wrote on 12 Mar 2021, 12:35 last edited by
        #3

        Hi @jsulm ,
        we have decided to move with QT for cross platform signature generation(private and public keys )and encryption, so is there any way this can be implemented in QT framework??
        Any specific libraries to provide encryption?

        J 1 Reply Last reply 12 Mar 2021, 12:51
        0
        • C cnag
          12 Mar 2021, 12:35

          Hi @jsulm ,
          we have decided to move with QT for cross platform signature generation(private and public keys )and encryption, so is there any way this can be implemented in QT framework??
          Any specific libraries to provide encryption?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 12 Mar 2021, 12:51 last edited by
          #4

          @cnag To calculate hashes there is https://doc.qt.io/qt-5/qcryptographichash.html
          For encryption there is nothing in Qt, but Qt already uses OpenSSL (which also can be installed using Qt Maintenance Tool) which you can use in your app.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 12 Mar 2021, 19:07 last edited by
            #5

            Hi,

            The QCA project might fit your needs.

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

            1 Reply Last reply
            1
            • C Offline
              C Offline
              cnag
              wrote on 15 Mar 2021, 11:17 last edited by
              #6

              Hi @SGaist ,
              How do i import QCA in QT environment after cloning from git?
              any suggestions would be really helpful as am using the windows machine .

              Thanks in advance .

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 15 Mar 2021, 20:00 last edited by
                #7

                Follow the instructions from the INSTALL file.

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

                C 1 Reply Last reply 17 Mar 2021, 11:35
                1
                • S SGaist
                  15 Mar 2021, 20:00

                  Follow the instructions from the INSTALL file.

                  C Offline
                  C Offline
                  cnag
                  wrote on 17 Mar 2021, 11:35 last edited by
                  #8

                  Hi @SGaist ,
                  I tried to follow instructions from INSTALL file , unfortunately couldn't import QCA .
                  am using windows machine and the instructions were given for Linux machine .Is there any alternative to import QCA in windows machine ?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 17 Mar 2021, 13:26 last edited by
                    #9

                    Citing INSTALL:

                    For Unix/Linux/Mac/Windows:
                    

                    What exactly did you do ?
                    What failed ?

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

                    C 1 Reply Last reply 17 Mar 2021, 13:32
                    0
                    • S SGaist
                      17 Mar 2021, 13:26

                      Citing INSTALL:

                      For Unix/Linux/Mac/Windows:
                      

                      What exactly did you do ?
                      What failed ?

                      C Offline
                      C Offline
                      cnag
                      wrote on 17 Mar 2021, 13:32 last edited by
                      #10

                      well i had to use cmake in order to import QCA in windows and getting an error in configuration process. am not sure whether some changes has to be made in cmake.txt files or install openSSL in order to run it.

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 17 Mar 2021, 14:09 last edited by
                        #11

                        Without giving more details, it's impossible to give you an answer.

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

                        1 Reply Last reply
                        0

                        1/11

                        12 Mar 2021, 11:35

                        • Login

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