Hi
I'm totaly beginner......
How to call java class?
JAVA:
_____________________________
_____________________________
I'm totaly beginner......
How to call java class?
JAVA:
_____________________________
B4X:
import java.io.FileInputStream
import java.security.Key
import java.security.KeyStore
import java.security.PrivateKey
import java.security.Signature
import java.text.SimpleDateFormat
import java.util.Date
import org.apache.commons.codec.digest.DigestUtils
Public class zoi {
Public static void Main( ) {
String taxnumber = "12345678"
String vmesni_rezultat = taxnumber;
String IssueDateTime = new SimpleDateFormat( "dd.MM.yyyy HH:mm:ss" ).format(new Date())
vmesni_rezultat = vmesni_rezultat + IssueDateTime
String InvoiceNumber = "12345"
vmesni_rezultat = vmesni_rezultat + InvoiceNumber
String BusinessPremiseID = "blag001"
vmesni_rezultat = vmesni_rezultat + BusinessPremiseID
String ElectronicDeviceID = "11245"
vmesni_rezultat = vmesni_rezultat + ElectronicDeviceID
String InvoiceAmount = "1245.56"
vmesni_rezultat = vmesni_rezultat + InvoiceAmount
byte[] podpisano = Null
Try {
FileInputStream file_inputstream = new FileInputStream("clientcert.jks")
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType())
keyStore.load(file_inputstream, "futest".toCharArray())
String alias = "itm storitve\\, špela pergar s.p."
Key privateKey = keyStore.getKey( alias, "futest".toCharArray())
Signature podpis = Signature.getInstance("SHA256withRSA")
podpis.initSign((PrivateKey)privateKey)
podpis.update(vmesni_rezultat.getBytes())
podpisano = podpis.sign()
} Catch ( Exception e ) {
'// napaka / error
e.printStackTrace()
}
'// zoi = izračunajMD5(elektronsko podpisan vmesni_rezultat) / zoi = claculateMD5(digitally signed //vmesni_rezultat)
String zoi = DigestUtils.md5Hex(podpisano)
System.out.println("32-mestni ZOI je: " + zoi);
}
}