P
polaris
hi all
I have a program to encrypt/decrypt a file using existing secret key
and it works good. I got a key from a friend and an encrypted file to
decrypt it but the program throws this exception:
java.io.StreamCorruptedException: invalid stream header: 87449FAA
Exception in thread "main" java.security.InvalidKeyException: No
installed provider supports this key: (null)
this is my code:
try
{
//throws exception here
ObjectInputStream in = new ObjectInputStream(new
FileInputStream("key.dat"));
key = (SecretKey)in.readObject();
byte[] raw = key.getEncoded();
skeySpec = new SecretKeySpec(raw, "AES");
in.close();
}
catch (Exception e)
{
System.out.println(e);
}
//creating of Cipher
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
I have a program to encrypt/decrypt a file using existing secret key
and it works good. I got a key from a friend and an encrypted file to
decrypt it but the program throws this exception:
java.io.StreamCorruptedException: invalid stream header: 87449FAA
Exception in thread "main" java.security.InvalidKeyException: No
installed provider supports this key: (null)
this is my code:
try
{
//throws exception here
ObjectInputStream in = new ObjectInputStream(new
FileInputStream("key.dat"));
key = (SecretKey)in.readObject();
byte[] raw = key.getEncoded();
skeySpec = new SecretKeySpec(raw, "AES");
in.close();
}
catch (Exception e)
{
System.out.println(e);
}
//creating of Cipher
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);