Why Char is Preferred Over String for Storing Passwords



Yes, Storing password in String object is not safe for following reasons −

  • String objects are immutable and until garbage collected, they remain in memory.

  • String being plain text can be tracked in memory dump of the application.

  • In log, String based password may be printed which can cause a problem.

Char[] can be cleared or wiped out after the job is done.

Updated on: 2020-02-24T10:31:39+05:30

169 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements