亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

php自定義hash函數(shù)實(shí)例

Original 2017-01-24 11:23:26 457
abstract:本文實(shí)例講述了php自定義hash函數(shù)實(shí)現(xiàn)方法。分享給大家供大家參考。具體分析如下:這里演示php實(shí)現(xiàn)的一個(gè)簡單hash算法,可以用來加密,不過這個(gè)函數(shù)過于簡單,不能用來解密function SimpleHash($str){    $n = 0;   // The magic happe

本文實(shí)例講述了php自定義hash函數(shù)實(shí)現(xiàn)方法。分享給大家供大家參考。具體分析如下:

這里演示php實(shí)現(xiàn)的一個(gè)簡單hash算法,可以用來加密,不過這個(gè)函數(shù)過于簡單,不能用來解密

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 = 'www.jb51.net';
print SimpleHash($TestString);
// returns: 1082

更多關(guān)于php自定義hash函數(shù)實(shí)例請(qǐng)關(guān)注PHP中文網(wǎng)(ipnx.cn)其他文章!   


Release Notes

Popular Entries