How to create and store password hashes with Blowfish in PHP

前端 未结 2 809
臣服心动
臣服心动 2020-12-24 06:41

1) How do you create secure Blowfish hashes of passwords with crypt()?

$hash = crypt(\'somePassword\', \'$2a$07$nGYCCmhrzjrgdcxjH$\');
         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 07:32

    You should store the entire output of crypt, there's not a lot of point in splitting it up, because you need to generate a new salt for each password you're hashing in any case. Using a fixed hidden salt as mentioned by Matt is wrong - the salt should be different for every hash.

    For more information see http://www.openwall.com/articles/PHP-Users-Passwords - I recommend using the phpass library because it handles generating a random salt for you, unlike crypt().

提交回复
热议问题