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 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?