I was wondering if I use PHP’s hash() function to generate sha512 hashes how would my MySQL table field look like in-order to be capable of holding the hashed password.
Here is my current MySQL password field layout
char(40)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A sha512 hash is represented as a 128 characters-long string.
For example, the following portion of code :
Will give this output :
Which means your
char(40)is far too small, and that you should use achar(128).Another solution would be to store it in a binary form, and not a string — which would mean 64 bytes.
But note it might be harder to deal with that representation, in some cases, I suppose.