For a password column, is there a mysql feature to store password hashed with “sha-256”? Or should I hash it from java code (like How to hash some string with sha256 in Java? ) before I store it in database and then hash the password input every time and compare with the database column value to authenticate?
TIA.
You can convert the value to hex and use a char(n) column with the appropriate length – 64 in this case. The conversion can be done in MySQL by using the
sha2function withhash_lengthset to 256.But for security reasons you should not store passwords hashed using SHA-256.
Instead use bcrypt or PBKDF2.
Related