輸入待尋字串
  <?php
  require("http://php.wilson.gs");  // 回首頁
  echo "http://php.wilson.gs/bible/group.php : mhash 雜湊函式庫";


mhash 雜湊函式庫

本函式庫共有 4 個函式

本函式庫支援多種雜湊演算法,例如最出名的 MD5、SHA1 或 GOST,還有其它多種的雜湊演算法,列示如下:

  • MHASH_MD5
  • MHASH_SHA1
  • MHASH_HAVAL
  • MHASH_RIPEMD160
  • MHASH_RIPEMD128
  • MHASH_SNEFRU
  • MHASH_TIGER
  • MHASH_GOST
  • MHASH_CRC32
  • MHASH_CRC32B

欲使用本函式庫要先下載 mhash-x.x.x.tar.gz,網址為 http://sasweb.de/mhash。當然還要編譯 mhash 程式庫,之後才能編譯 PHP 程式,在編譯 PHP 程式時,記得要加 --with-mhash 選項打開系統的 mhash 功能。

本函式庫適合用來產生檢查碼 (checksums)、數位代訊息或者其它功能,如下例:

<?php
$input 
"Let us meet at 9 o' clock at the secret place.";
$hash mhash(MHASH_SHA1$input);
print 
"雜湊值為 ".bin2hex($hash)."\n";
?>

在瀏覽器看到的字串是

雜湊值為 d3b85d710d8f6e4e5efd4d5e67d041f9cecedafe

mhash_get_hash_name:取得雜湊演算法名稱。
mhash_get_block_size:取得雜湊方式的區塊大小。
mhash_count:取得雜湊 ID 的最大值。
mhash:計算雜湊值。


[ 上一頁 /bible/group.php 下一頁 ]



本站置於 NEC BIGLOBE 地球村網際網路  echo "Copyright © 1999-2000, Wilson Peng";
  mail("wilson@biglobe.net.tw", "Feedback", $message);
  ?>