Why Char array is preferred over String for storing password?

In password why is character array used and not a string?
Just read this somewhere can anyone clear this thing.

1 Like

To be honest, a hash is preferred over any array or string when it comes to passwords.

Details:
Hashed Passwords are preferred to make it difficult for people with malicious intent to take away a user’s password. The logic is as follows:
An algorithm will hash a string to the same value no matter how many times you try it, the result will be the same. Instead of storing the full password, depending upon the complexity, the first ‘n’ characters are stored in the database which is enough to compare. Given that the system is working with the same hashing algorithm and salts, the hash of a given string will be the same and it can be compared against the stored characters in database. The simplest of character comparisons can be done in arrays that can be a probable reason why this is the way it is.

2 Likes

This is because char takes small space.