编程语言
首页 > 编程语言> > php – crypt()无法正常运行

php – crypt()无法正常运行

作者:互联网

我使用crypt如下:

$pass = crypt($pass, 'd4');

用于插入和验证mysql表的密码.问题是如果密码相似,它会产生类似的结果.是否有算法可以保证不同密码的结果不同?

解决方法:

使用hash()并选择适合你的散列算法(如果可能的话,比MD5强,但不要一直到SHA512)

crypt()的手册页中,您将找到:

The standard DES-based crypt() returns the salt as the first two
characters of the output. It also only uses the first eight characters
of str, so longer strings that start with the same eight characters
will generate the same result (when the same salt is used).

这应该解释为什么你得到相同的结果.

标签:crypt,php
来源: https://codeday.me/bug/20190726/1542209.html