How to protect our java program from decompilation so that no one could see the source code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

How to protect our java program from decompilation so that no one could see the source code?

Just like if I make a program in java which asks user to enter a certain password to show some particular stuff. But if someone decompile the .class file, he could easily get the password from the java code and that's not good.

26th Aug 2018, 2:59 PM
Tanish Kushwaha
Tanish Kushwaha - avatar
4 Answers
+ 1
You can obfuscate the code. but this is not a solution. the obfuscation only scrambles the code. it will be more dificult, but it still acessible. Your password must be encrypted or be out of the code (better solution).
26th Aug 2018, 8:18 PM
Fábio D'Almeida Oliveira
Fábio D'Almeida Oliveira - avatar
+ 14
The correct term is 'obfuscation'. There are many tools available to obfuscate source code. Just search for them on the internet ;)
26th Aug 2018, 6:37 PM
Tashi N
Tashi N - avatar
+ 7
wait, when you take user input and store the input inside variable, it's stored in RAM your original source code will not change. But you should obfuscate the code if you are hard coding the password
28th Aug 2018, 3:14 AM
code learner
code learner - avatar
+ 3
Yea I guess it's better to write the password block out of the code like in a binary file.
27th Aug 2018, 4:59 AM
Tanish Kushwaha
Tanish Kushwaha - avatar