Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

BouncyCastle RC4 and Openssl RC4

843810Feb 23 2005 — edited Feb 23 2005
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 23 2005
Added on Feb 23 2005
4 comments
1,242 views