can someone please explain me how to sign a string or byte array using private key? PLEASE. two weeks I'm trying to achieve it. I have code:
private static byte[] createSignature(byte[] file) {
byte[] signature = null;
try {
java.security.KeyStore keyStoreFile = java.security.KeyStore
.getInstance("PKCS12");
keyStoreFile.load(new FileInputStream("keyStore.pfx"),
"password".toCharArray());
// nuskaitomas privatus raktas iš failo
PrivateKey privateKey = (PrivateKey) keyStoreFile.getKey(
"alais", "password".toCharArray());
Signature dsa = Signature.getInstance(SHA1withRSA);
dsa.initSign(privateKey);
dsa.update(file, 0, file.length);
signature = dsa.sign();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return signature;
}
but this is just a signature. .