[php] crypt() 函數返回使用 DES、Blowfish 或 MD5 加密的字符串
說明
確切的算法依賴於 salt 參數的格式和長度。
下面是與 crypt() 函數一起使用的一些常量。在安裝時,由 PHP 設置這些常量:
[CRYPT_SALT_LENGTH]
[CRYPT_STD_DES]
[CRYPT_EXT_DES]
[CRYPT_MD5]
[CRYPT_BLOWFISH]
範例
在本例中,我們將測試不同的算法:
<?php
if (CRYPT_STD_DES == 1)
{
echo "Standard DES: ".crypt("hello world")."\n<br />";
}
else
{
echo "Standard DES not supported.\n<br />";
}
if (CRYPT_EXT_DES == 1)
{
echo "Extended DES: ".crypt("hello world")."\n<br />";
}
else
{
echo "Extended DES not supported.\n<br />";
}
if (CRYPT_MD5 == 1)
{
echo "MD5: ".crypt("hello world")."\n<br />";
}
else
{
echo "MD5 not supported.\n<br />";
}
if (CRYPT_BLOWFISH == 1)
{
echo "Blowfish: ".crypt("hello world");
}
else
{
echo "Blowfish DES not supported.";
}
?>
輸出類似(依賴於操作系統):
Standard DES: $1$r35.Y52.$iyiFuvM.zFGsscpU0aZ4e.
Extended DES not supported.
MD5: $1$BN1.0I2.$8oBI/4mufxK6Tq89M12mk/
Blowfish DES not supported.
公告版位
礁溪溫泉套房,位於宜蘭縣礁溪國小旁,近麥當勞,離礁溪火車站、首都客運、葛瑪蘭汽車客運約5分鍾車程,礁溪溫泉套房出租,您不需要再行添購傢俱,只需要帶幾件衣服,就能輕輕鬆鬆住進礁溪溫泉套房,天天在礁溪溫泉套房洗溫泉唷!意洽:游媽媽,電話0939711360,4500~4900元/月
- May 24 Tue 2011 09:22
[php] crypt() 函數返回使用 DES、Blowfish 或 MD5 加密的字符串
全站熱搜
留言列表
發表留言