PHPTS:一键免费搭建 Nginx + PHP + MySQL 运行环境

md5

(PHP 4, PHP 5, PHP 7)

md5计算字符串的 MD5 散列值

Warning

It is not recommended to use this function to secure passwords, due to the fast nature of this hashing algorithm. See the Password Hashing FAQ for details and best practices.

说明

md5 ( string $str [, bool $raw_output = FALSE ] ) : string

使用 » RSA 数据安全公司的 MD5 报文算法计算 str 的 MD5 散列值。

参数

str

原始字符串。

raw_output

如果可选的 raw_output 被设置为 TRUE,那么 MD5 报文摘要将以16字节长度的原始二进制格式返回。

返回值

以 32 字符十六进制数字形式返回散列值。

范例

Example #1 md5() 范例

<?php
$str 
'apple';

if (
md5($str) === '1f3870be274f6c49b3e31a0c6728957f') {
    echo 
"Would you like a green or red apple?";
}
?>

参见

  • md5_file() - 计算指定文件的 MD5 散列值
  • sha1_file() - 计算文件的 sha1 散列值
  • crc32() - 计算一个字符串的 crc32 多项式
  • sha1() - 计算字符串的 sha1 散列值
  • hash() - 生成哈希值 (消息摘要)
  • crypt() - 单向字符串散列
  • password_hash() - 创建密码的散列(hash)