If you save the password in text form in your application, someone can read it by playing with memory dumps, regardless of the language or runtime that you use.
To reduce the likelihood of this, just keep the password in plain text when you really need to, then reset or encrypt it. It should be noted here that JPasswordField returns char [], not a string. This is because you are not in control when String disappears. While you also cannot control when the char [] disappears, you can fill it with junk when you are done with the password.
I say “reduce” because it will not stop anyone. As long as the password is in memory, it can be restored, and since decryption should also be part of the supplied one, it can also be cracked, leaving your password open.
Michael Lloyd Lee mlk
source share