How are variables saved after compilation?

I have in my program (written in Java) a variable:

String myPassword 

After compiling the code with Android Studio, I get an Android app, and I would like to let other people use it.

But I'm afraid: is it possible for users to get the variable value (password) from the application?

Let's say the password value is "myPass". Its binary code is:

01101101 01111001 01010000 01100001 01110011 01110011

Will the application binary file contain this sequence?

+8
java compilation
source share
1 answer

If you decompile your classes with javap -c -p -constants , for example, you will see these lines:

 public class DeleteMe { private static final String test = "def"; public static void main(String[] args) { String test = "abc"; } } 

will give (important two lines):

 private static final java.lang.String test = "def"; ldc #2 // String abc 

Otherwise, storing passwords inside your application is really bad, usually people use some kind of database where passwords are stored, for example.

You also need to read about String and char[] for passwords.

+2
source share

All Articles