代码:
echo password_hash("stackoverflow", PASSWORD_DEFAULT, ['salt' => 'twenty-one-characters'] );
结果:
Warning: password_hash(): Provided salt is too short: 21 expecting 22
代码:
echo password_hash("stackoverflow", PASSWORD_DEFAULT, ['salt' => 'twenty-one-charactersA'] );
结果:
$2y$10$dHdlbnR5LW9uZS1jaGFyYOVyX13hK9eb4/KXMAkHsAJX..YR7t/32
代码:
echo password_hash("stackoverflow", PASSWORD_DEFAULT, ['salt' => 'twenty-one-charactersB'] );
$2y$10$dHdlbnR5LW9uZS1jaGFyYOVyX13hK9eb4/KXMAkHsAJX..YR7t/32
问题:
如您所见,通过将 A 和 B 附加到 21 个字符串,我们创建了两种不同的 22 个字符的盐,但是,哈希是相同的!那就是第22个字符被忽略了?如果它被忽略,那么为什么它要求 22 个字符的盐?