《PHP實例:php自定義hash函數實例》要點:
本文介紹了PHP實例:php自定義hash函數實例,希望對您有用。如果有疑問,可以聯系我們。
本文實例講述了php自定義hash函數實現辦法.分享給大家供大家參考.具體分析如下:PHP實戰
這里演示php實現的一個簡單hash算法,可以用來加密,不過這個函數過于簡單,不能用來解密PHP實戰
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; }
調用辦法:
PHP實戰
$TestString = 'www.jb51.net'; print SimpleHash($TestString); // returns: 1082
希望本文所述對大家的php程序設計有所贊助.PHP實戰
歡迎參與《PHP實例:php自定義hash函數實例》討論,分享您的想法,維易PHP學院為您提供專業教程。