Art*_*nix 10
你可以查看长度
if( strlen($hash) == 60 )
Run Code Online (Sandbox Code Playgroud)
PASSWORD_BCRYPT - 使用CRYPT_BLOWFISH算法创建哈希.这将使用"$ 2y $"标识符生成标准的crypt()兼容哈希.结果将始终为60个字符的字符串,或者失败时为FALSE.
http://php.net/manual/en/function.password-hash.php
此外,您可以检查$ 2y $标识符.像这样的regx
preg_match('/^\$2y\$/', $hash );
Run Code Online (Sandbox Code Playgroud)
或者甚至strpos($hash, '$2y$') 虽然我不确定是什么偏移它会放弃我的头脑.
所以举个例子
$hash = '$2y$10$ug8B6Pxs546eQBNICxsEOOH3NgpXjOIo.g4rf1FPZk2xJncWcFUpu';
if( strlen($hash) == 60 && preg_match('/^\$2y\$/', $hash ))
Run Code Online (Sandbox Code Playgroud)
你可以非常自信,如果它开始$2y$并且长度是60,那么它就是哈希.可能会有非零的机会遇到类似的东西,但它实际上是无法的.
| 归档时间: |
|
| 查看次数: |
1683 次 |
| 最近记录: |