| Start |
|---|
| Creating a password hash Create password hashes using The third parameter is not mandatory. The On PHP lower than 5.5.0 the If you are not able to use those, you can implement password hashing with Salt for password hashDespite of reliability of crypt algorithm there is still vulnerability against rainbow tables (opens new window). That's the reason, why it's recommended to use salt. A salt is something that is appended to the password before hashing to make source string unique. Given two identical passwords, the resulting hashes will be also unique, because their salts are unique. A random salt is one of the most important pieces of your password security. This means that even with a lookup table of known password hashes an attacker can’t match up your user’s password hash with the database password hashes since a random salt has been used. You should use always random and cryptographically secure salts. Read more (opens new window) With Even when this is discouraged, you can use the Important. If you omit this option, a random salt will be generated by password_hash() for each password hashed. This is the intended mode of operation. The salt option has been deprecated (opens new window) as of PHP 7.0.0. It is now preferred to simply use the salt that is generated by default. |
| Determine if an existing password hash can be upgraded to a stronger algorithm If you are using the If the password_* functions are not available on your system (and you cannot use the compatibility pack linked in the remarks below), you can determine the algorithm and used to create the original hash in a method similar to the following: |
| Verifying a password against a hash
All supported hashing algorithms store information identifying which hash was used in the hash itself, so there is no need to indicate which algorithm you are using to encode the plaintext password with. If the password_* functions are not available on your system (and you cannot use the compatibility pack linked in the remarks below) you can implement password verification with the Syntax
RemarksPrior to PHP 5.5, you may use the compatibility pack (opens new window) to provide the With or without the compatibility pack, correct Bcrypt functionality through Note: If you use PHP 5.5 or below you're using an unsupported version of PHP (opens new window) which does not receive any security updates anymore. Update as soon as possible, you can update your password hashes afterwards. Algorithm SelectionSecure algorithms
Insecure algorithmsThe following hashing algorithms are insecure or unfit for purpose and therefore should not be used. They were never suited for password hashing, as they're designed for fast digests instead of slow and hard to brute force password hashes. If you use any of them, even including salts, you should switch to one of the recommended secure algorithms as soon as possible. Algorithms considered insecure:
Some algorithms can be safely used as message digest algorithm to prove authenticity, but never as password hashing algorithm:
Note, strong hashes such as SHA256 and SHA512 are unbroken and robust, however it is generally more secure to use bcrypt or argon2 hash functions as brute force attacks against these algorithms are much more difficult for classical computers. |
Read Article
https://develop.horje.com/learn/1434/reference