How to create a database with sha2
there is only this information in the documentation
mysql> SELECT SHA2('abc', 224);
-> '23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7'
PHP 8 and MYSQL 8 sha2 encryption
Not sure what you are asking. You create the database just like you would any other. If you want to store a hash in a table column, you just need a character type of column that is large enough to hold the number of characters generated by whichever type of hash you've chosen to use (e.g., looks like you'd need 56 characters for your example using a 224-bit SHA2).
The examples in the documentation SELECT the function call here so that when you try the example, you can see what value it returns. You can call the functions anywhere in the sql query statement where you want to use the value that the function returns.
I want to create the field sha2 to make the password sh2
The sha2() function should not be used for password hashing. Use php's password_hash() and password_verify().
pbismad Use php's password_hash() and password_verify().
Have to admit that -- for mainly subjective reasons -- I'm not a big fan of that, in that it means I have to do an extra step after submitting a log-in query to do the password_verify()
, as opposed to just checking if I got a row returned by the query or not. However, I am a fan of the fact that using those functions probably help prevent devs who don't keep up with all the possible security loopholes of doing all the hashing yourself from doing something insecure. So maybe I'll join you soon, as I really don't want to keep up with those things if I don't have to.