my dog learned polymorphism*
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 Java 8 in Action this week in the Java 8 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: 39576
    
  27
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 - updated with new look and Ping home screen widget
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36579
    
  16
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: 39576
    
  27
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: 39576
    
  27
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: encryption and decryption
 
Similar Threads
External Database Changes sending notifications to Entity Beans
how to accesss Private Java Clas
singleton class
class diagrams
singleton class