Hello,
I am trying to encrypt a message using RSA algo but getting the following error:
java.io.StreamCorruptedException: invalid stream header
at java.io.ObjectInputStream.readStreamHeader(ObjectI nputStream.java:753)
at java.io.ObjectInputStream.<init>(ObjectInputStream .java:268)
public static final String PUBLIC_KEY_FILE = "C:/TXT.key"; final String originalText = "Text to be encrypted "; ObjectInputStream inputStream = null; FileInputStream f= new FileInputStream(PUBLIC_KEY_FILE); // getting error on the below line inputStream = new ObjectInputStream(f); final PublicKey publicKey = (PublicKey) inputStream.readObject(); final byte[] cipherText = encrypt(originalText, publicKey);
Please guide.
Thanks