Connecting Tech Pros Worldwide Help | Site Map

Encrypt image (jpg) in C#.NET and Decrypt the same in Java

Newbie
 
Join Date: Apr 2009
Posts: 3
#1: Apr 23 '09
I have an image (.jpg/.bmp) to be encrypted in C#.NET. The same encrypted image has to be Decrypted in Java. Any help on this is appreciated.
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#2: Apr 23 '09

re: Encrypt image (jpg) in C#.NET and Decrypt the same in Java


What kind of encryption were you thinking about? Theoretically, if you use the same algorithm on both sides (but reverse for decrypting of course), it should work. Of course, you may have to pass a key or something like that.

Greetings,
Nepomuk
Newbie
 
Join Date: Apr 2009
Posts: 3
#3: Apr 23 '09

re: Encrypt image (jpg) in C#.NET and Decrypt the same in Java


Thanks a Lot!

I am trying to use any algorithm. We can use a common DES algorithm on both c#.net and Java. But DES is very insecure and is not recommended to be used.

I would rather prefer Rijndael Algorithm for encryption on C#.Net. I am not sure what algorithm is equivalent to this one on Java. My guess is AES algorithm on Java.
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#4: Apr 23 '09

re: Encrypt image (jpg) in C#.NET and Decrypt the same in Java


According to Wikipedia, "Rijndael Algorithm" is just another name for AES. Mind you, algorithms aren't language specific, you could implement any of the standard algorithms in any of the standard languages. I don't know if they are available within the standard libraries, but you could always implement them yourself.

Greetings,
Nepomuk
Newbie
 
Join Date: Aug 2009
Posts: 5
#5: Sep 26 '09

re: Encrypt image (jpg) in C#.NET and Decrypt the same in Java


Probably today the more secure algorithm, and the most adopted, for symmetric encryption is AES.
You can use it to encrypt your image (as file stream) in C# and decrypt in Java. Remember that AES is a standard algorithm and the C# and JAVA implementation must be the same. If a encrypted stream is encrypted with a standard symmetric algorithm in one of the two platform, it will be decrypted by the other, due to the standardization of the algorithm.
To quickly encrypt your image with c# you can try Bonnie.NET at http://www.we-coffee.com/bonnie.aspx. It is a free dll that manages all cryptographic needs when developing with .NET
Reply