Importing JAVA libraries in QT
-
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
-
@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/ -
@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. -
Hi,
The QCA project might fit your needs.
-
Follow the instructions from the INSTALL file.
-
Citing
INSTALL
:For Unix/Linux/Mac/Windows:
What exactly did you do ?
What failed ? -
Without giving more details, it's impossible to give you an answer.