openssl_digest
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
openssl_digest — 计算摘要
说明
使用给定的方法计算给定数据的摘要哈希值,并返回一个原始的或16进制编码的字符串。
参数
data
-
给定的数据。
digest_algo
-
要使用的摘要方法,比如 "sha256", 查看 openssl_get_md_methods() 函数获取更多可用的摘要方法。
binary
-
为
true
时将会返回原始输出数据,否则返回值将会是16进制。
返回值
成功,返回摘要哈希值, 或者在失败时返回 false
.
错误/异常
如果通过 digest_algo
参数传递的是未知的摘要算法,将会抛出 E_WARNING
级的错误。
+添加备注
用户贡献的备注 1 note
mwgamera at gmail dot com ¶
11 years ago
The second argument should be one of the values returned by openssl_get_md_methods() rather than hash_algos(). ‘Hash’ and ‘OpenSSL’ are independent extensions and support different selection of digest algorithms. Notably, Hash supports some non-cryptographic hashes like adler or crc.
备份地址:http://www.lvesu.com/blog/php/function.openssl-digest.php