With the last version of PHP, there are many actual methods included in the core language that you should use in your code files. These will help you a lot that you might have working out the easist way to creat a salt. So, if you are able to do, I suggest you to switch to using this method everywhere (if possible) you generate passwords.
Hashing Logic is as simple as you doing this:
password_hash('YouRSuperSecure&(*$p880$0w0rd!', PASSWORD_BCRYPT);
Here, you pass in the string that you want to hash, and the method of hashing that you’re looking to use. You can add the second parameter, and stick to the default that PHP chooses to the best.
By default the method will use a cost of 10, which is a good level to start at, however if you want to change this, you can pass through the cost as a third parameter as an array of options.
See below example sets the cost value to 16 (min is 4, max is 30)
Example:-
password_hash('YouRSuperSecure&(*$p880$0w0rd!', PASSWORD_BCRYPT, ['cost' => 16]);
It’s just that easy like anything! Enjoy!.
Please do share our blog with interested coders and those you always ready to learn.