Converting a byte [] to PrivateKey in java for digital signature
I need to digitally sign a String using the SHA-1 digest algorithm first and then apply the RSA algorithm, using a PrivateKey to sign it. I already have the PrivateKey stored in my database as data type char(250) in base64. My problem is that I don't know how to convert it into a PrivateKey for using it for signing in: Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, privateKey); byte[] cipherText = cipher.doFinal(digest); Digest was an array of bytes to which I applied the SHA-1 digest algorithm: MessageDigest md = MessageDigest.getInstance("SHA-1"); byte [] ba =