PHP与Linux/bash的mkpasswd生成SHA-256加盐哈希结果不一致?(已解决)
PHP crypt与mkpasswd SHA-256哈希结果不一致问题(已解决)
我可以在PHP中通过加盐和SHA-256算法进行哈希操作:
echo crypt('testpassword','$5$rounds=5000$testsalt$');
执行后得到的哈希值为:
=5rf7xsfKjXFA
但在Linux/bash中使用mkpasswd执行相同操作时,得到的结果却不同:
mkpasswd -m sha-256 -S testsalt testpassword
此时生成的哈希值为:
$5$testsalt$8NbtxBXDUq60UB.kmvqYOHepmEdmXS39tViByKR.UU2
有人能帮忙解决这个问题吗?——已解决,详见评论。
使用环境版本
PHP版本
php --version PHP 7.0.33-0+deb9u12 (cli) (built: Oct 26 2021 17:51:39) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.33-0+deb9u12, Copyright (c) 1999-2017, by Zend Technologies
mkpasswd版本
mkpasswd 5.2.17 Copyright (C) 2001-2008 Marco d'Itri This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
内容的提问来源于stack exchange,提问作者Prefect
相关产品推荐
相关产品推荐

