Hi all,
I've got a compatability problem in using RC4 both in Openssl and BouncyCastle.
This is what I am doing in openssl to encrypt 'original' file and create 'original_encr' file.
openssl enc -rc4 -in original -out original_encr -e
which asks for a password and I gave 112233 and it reconfirms the password and creates the 'original_encr' file.
Now, I can even decrypt this file in openssl using -d option.
My problem started when I tried to decrypt the same file in java using BouncyCastle rc4.
I am doing it like this.
byte[] keybytes = "112233".getBytes();
SecretKey skeySpec = new SecretKeySpec(keybytes, "RC4");
Cipher cipher = Cipher.getInstance("RC4");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
//databytes is read from file using FileInputStream
byte[] decrypted = cipher.doFinal(databytes);
I am not getting any errors at run time. But when I see the result file, every thing is junk and obviously 'original' file is not decrypted.
Am i doing right? Can any one show me the right direction?
varma