douzhang7603 2014-05-24 20:56
浏览 187
已采纳

Php - crypt的安全级别('password','$ 2a $ 12 $'。$ salt)等于password_hash()方法[重复]

This question already has an answer here:

The question my seem nerd but I'm a newbie to those PHP password encryption libraries and methods.

I found a lot of posts about use bcrypt for highest level of secure password hashing.

I found out that in PHP 5.5, we can use password_hash() function to create a bcrypt password. But most of hosting web servers still don't support PHP 5.5. It is really awkward.

I also found out another commonly use function crypt() which support six hashing algorithms. It is fortunate that this function can also produce bcrypt hashed password by providing proper format string such as $2a$12$. Again official php docs says that it is supported in PHP 5. Therefore I decided to use this one for my project.

I just want to know that the security level of this crypt() function (with $2a$12$) is equal to password_hash() function of PHP 5.5.

I also found out that password_hash() compatible library for lower version of PHP. Is this library provide other advantages over crypt() function?

Please, share your any suggestions. I'm really ambiguous now. Thanks in advance.

</div>
  • 写回答

1条回答 默认 最新

  • dongxixiu9134 2014-05-24 21:07
    关注

    $2a$ hashes are not secure, see this page for details. PHP 5.3.7 and above uses $2y$. crypt can generate secure hashes, but you need to provide a salt manually. If you generate a weak salt, then the hash won't be secure enough.

    Because of this, I suggest to use password_compat. It was developed by Anthony Ferrara who implemented the password_hash functions into PHP 5.5. It provides an easy and secure way to hash and compare passwords.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程