The below class is my security key provider for encryption.
public class MySecretKey {
private String key="2sfdsdf7787fgrtdfg#$%@cj5";
...
//Some Util methods goes on Here .
}
First I didn't belive that one can access the private
data without a getter, but, My goodness, I am able to see the key in the console now .
And somewhere else using reflection we can see the code like below :
public static void main(String[] args) throws Exception {
Stacker myClass = new Stacker();
Field key= myClass.getClass().getDeclaredField("key");
field1.setAccessible(true);
System.out.println(key.get(myClass));
}
How can I hide my key from outside my class :( ,even private
keyword also not helping me in case of Reflection.
Please give me some hint .
Thanks in advance.