In a scenario where you are designing a system that will store and manipulate confidential data (like passwords) which will be stored in the form of strings, how would you ensure that this sensitive data is not prone to security issues related to string handling?

  • Use String and encrypt it
  • Use String and mark it as 'final'
  • Use StringBuilder and set 'secure' flag
  • Use char[] to store passwords
To enhance security for sensitive data like passwords, you should use a char[] to store passwords instead of a String. This is because String objects are immutable and linger in memory, making them vulnerable to security risks. char[] can be overwritten, and you can zero it out after use. The other options do not provide similar security benefits.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *