PASSWORD_DEFAULT vs PASSWORD_BCRYPT

谁都会走 提交于 2019-11-30 17:28:58

Currently PASSWORD_BCRYPT is the only algorithm supported (using CRYPT_BLWFISH), therefore there is currently no difference between PASSWORD_DEFAULT and PASSWORD_BCRYPT. The purpose of PASSWORD_DEFAULT is to allow for the inclusion of additional algorithms in the future, whereupon PASSWORD_DEFAULT will always be used to apply the strongest supported hashing algorithm.

Cost is related to the number of iterations of the algorithm that are executed, and affects the speed of calculation as well as the hash value generated. Higher costs take longer to execute, slowing brute force attacks

Per the documentation PASSWORD_DEFAULT is meant to be future proof

From the docs:

PASSWORD_DEFAULT - Use the bcrypt algorithm (default as of PHP 5.5.0). Note that this constant is designed to change over time as new and stronger algorithms are added to PHP. For that reason, the length of the result from using this identifier can change over time. Therefore, it is recommended to store the result in a database column that can expand beyond 60 characters (255 characters would be a good choice).

There is no difference between PASSWORD_DEFAULT and PASSWORD_BCRYPT for the moment (http://www.php.net/manual/en/password.constants.php). The cost will depend on the number of rounds the hash will be applied. It is also explained in the link above. If you want to increase the security of your hash, you better increase the number of rounds instead of the length.

Another good example is shown here: https://wwphp-fb.github.io/faq/security/passwords/

Currently PASSWORD_DEFAULT is PASSWORD_BCRYPT and as language and cryptography progress there will be different types of algorithms supported. PASSWORD_DEFAULT will get replaced with that new type of algorithm (for example Argon2). Good choice is to always use the PASSWORD_DEFAULT.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!