Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes encryption and decryption Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "encryption and decryption" Watch "encryption and decryption" New topic
Author

encryption and decryption

Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
How to encrypt a class so that can not be decompiled by any decompiler and how to decrypt this class?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
That's not possible. A JVM must be able to access the unencrypted bytecode at some point in order to execute it, and a technically savvy attacker can instrument the JVM to retrieve that bytecode.


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39419
    
  28
That is almost as easy as trisecting the angle, squaring the circle and drawing a map which really requires four colours to distinguish all the countries on it.
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
Ulf Dittmer wrote:That's not possible. A JVM must be able to access the unencrypted bytecode at some point in order to execute it, and a technically savvy attacker can instrument the JVM to retrieve that bytecode.


I used decompiler to decompile my classes and it was so easy to detect the code
so how to encrypt parts of it to prevent that?

do you mean that we can encrypt only parts of the code such as certain method in the class
and leave another method that calls the encrypted one not encrypted

sorry I did not understand your opinion enough would you please explain it more
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
The key words of my post were "That's not possible." If you don't want anyone decompiling code, then don't give it to them. That's the only really safe solution.
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
I tried to decompile a class and an error was present that there is a method can not find it
and when I tried to recompile the class with the same software, the operation failed

I thought about encryption and decryption but i failed to do the same with my class
do you have an idea about why these errors occurred in this class ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
Decompilers aren't perfect; sometimes they miss things or can't figure out something, and one would have to fix the generated source code manually. It's not unusual at all.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: encryption and decryption