codecamp

PHP8 sodium_crypto_pwhash_str_verify

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_pwhash_str_verify — 验证密码是否与哈希匹配

说明

sodium_crypto_pwhash_str_verify(string $hash, string $password): bool

检查使用 sodium_crypto_pwhash_str() 创建的密码哈希是否与给定的纯文本密码匹配。请注意,这些参数的顺序与类似 password_verify() 函数中的相同参数相反。

参数 

hash

一个由 password_hash() 创建的散列值。

password

用户的密码。

返回值 

如果密码和哈希匹配,则返回 true,否则返回 false。

注释 

注意:哈希值是使用 Argon2ID 算法计算的,可抵御 GPU 和侧信道攻击。

参见 

  • sodium_crypto_pwhash_str() - 获取 ASCII 编码的哈希值
  • Pasword_hash() - 巓建密码的散列(hash)
  • password_verify() - 验证密码是否和散列值匹配


PHP8 sodium_crypto_pwhash_str_needs_rehash
PHP8 sodium_crypto_pwhash_str
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定