PHP md5函数使用方法
md5
(PHP 4, PHP 5, PHP 7, PHP 8)
md5 — 计算字符串的 MD5 散列值
警告
由于此函数依赖的算法已不足够复杂,不推荐使用此函数对明文密码加密。
说明
md5(string $string
, bool $binary = false
): string
使用 » RSA 数据安全公司的 MD5 消息摘要算法 计算 string
的 MD5 散列值,并返回该散列值。
参数
string
要计算的字符串。
binary
如果可选的 binary
被设置为 true
,那么 md5 摘要将以 16 字符长度的原始二进制格式返回。
返回值
以 32 字符的十六进制数形式返回散列值。
示例
<?php
$str = 'apple';
if (md5($str) === '1f3870be274f6c49b3e31a0c6728957f') {
echo "Would you like a green or red apple?";
}
?>

扫码添加站长好友
多年IT从业经验
涉及网络、机房、服务器、网站建设等领域