Re: Doubt in Security basics
Roland Illig <[email protected]> Tue, 15 Feb 2005 17:42:06 +0100
| Newsgroups | gmane.comp.security.programming |
|---|---|
| Message-ID | <[email protected]> |
Babu Kopparam wrote:
>
> Hi! List,
>
> Probably i feel this doubt is related with basic knowledge.
>
> Whenever capturing the password, char[] is used instead of String object. What purpose does this solve.
> --- I am referring to JAVA.
It seems to me that it's a matter of who controls the password. When you
use java.lang.String for passwords, you never know where the string
containing the password is saved, and when the password will be erased.
Using a char[] allows you to erase the password after use:
for (int i = 0; i < password.length; i++)
password[i] = 'X';
In that case you just need no make sure that the char[] is never given
to any other function which could copy the password out of the "safe"
storage.
Roland