php自定義hash函數(shù)實(shí)例
更新時(shí)間:2015年05月05日 09:16:05 作者:企鵝不笨
這篇文章主要介紹了php自定義hash函數(shù),實(shí)例分析了hash函數(shù)的實(shí)現(xiàn)技巧,可實(shí)現(xiàn)簡(jiǎn)單的加密功能,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了php自定義hash函數(shù)實(shí)現(xiàn)方法。分享給大家供大家參考。具體分析如下:
這里演示php實(shí)現(xiàn)的一個(gè)簡(jiǎn)單hash算法,可以用來(lái)加密,不過(guò)這個(gè)函數(shù)過(guò)于簡(jiǎn)單,不能用來(lái)解密
function SimpleHash($str){
$n = 0;
// The magic happens here:
// I just loop trough all letters and add the
// ASCII value to a integer variable.
for ($c=0; $c < strlen($str); $c++)
$n += ord($str[$c]);
// After we went trough all letters
// we have a number that represents the
// content of the string
return $n;
}
調(diào)用方法:
$TestString = 'm.fzitv.net'; print SimpleHash($TestString); // returns: 1082
希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
PHP開發(fā)規(guī)范手冊(cè)之PHP代碼規(guī)范詳解
對(duì)于PHP入門學(xué)習(xí)的童鞋來(lái)說(shuō),了解PHP開發(fā)規(guī)范可以少走很多彎路,網(wǎng)上各種PHP開發(fā)規(guī)范也很多,我結(jié)合自身使用PHP的情況,來(lái)說(shuō)說(shuō)我所理解的PHP開發(fā)規(guī)范。2011-01-01
解決PHP程序運(yùn)行時(shí):Fatal error: Maximum execution time of 30 seconds
最近做的程序中涉及到的循環(huán)比較多且處理的情況較復(fù)雜,在運(yùn)行程序時(shí)出現(xiàn)執(zhí)行超時(shí)提示如下:Fatal error: Maximum execution time of 30 seconds exceeded in D:\php\AppServ\www\sum3\test.php on line 3通過(guò)在網(wǎng)上搜索,找到了解決方法和大家分享,下面來(lái)一起看看吧。2016-11-11

