**:
/// /// 計算檔案的 md5 值///
/// 要計算 md5 值的檔名和路徑
/// md5 值16進製制字串
public static string md5file(string filename)
/// /// 計算檔案的雜湊值
///
/// 要計算雜湊值的檔名和路徑
/// 演算法:sha1,md5
/// 雜湊值16進製制字串
public static string hashfile(string filename, string algname)
/// /// 計算雜湊值
///
/// 要計算雜湊值的 stream
/// 演算法:sha1,md5
/// 雜湊值位元組陣列
public static byte hashdata(system.io.stream stream, string algname)
if (string.compare(algname, "sha1", true) == 0)
else
algorithm = system.security.cryptography.md5.create();
}return algorithm.computehash(stream);
}/// /// 位元組陣列轉換為16進製表示的字串
///
public static string bytearraytohexstring(byte buf)
}return returnstr;
}
備註:檔案越大,耗費時間越多。乙個幾kb的檔案計算一次需要100毫秒左右,大檔案沒試過。
C計算檔案的MD5值
filemd5.c檔案 include include include define f x,y,z x y x z define g x,y,z x z y z define h x,y,z x y z define i x,y,z y x z define rl x,y x y x 32 y x...
python計算檔案的MD5值
一 import sys import hashlib import os.path filename sys.argv 1 if os.path.isfile filename fp open filename,rb contents fp.read fp.close print hashlib....
python計算檔案的md5值
最近要開發乙個基於python的合併資料夾 目錄的程式,本來的想法是基於修改時間的比較,即判斷檔案有沒有改變,比較兩個檔案的修改時間即可。這個想法在windows的pc端下測試沒有問題。但是當把乙個檔案從pc端複製到優盤時出現了乙個問題,複製到優盤的檔案比pc端的檔案慢了兩秒鐘!這裡我用的複製函式是...