我想用用戶交互創建散列函數。 這個想法是,用戶選擇他/她想要的散列(即md5,sha1等等),程序完成剩下的部分。 我的代碼: hashstring = "hashlib" + finalHash
filePath = open(chosenFile, 'rb')
data = filePath.read(8192)
if not data:
ret
這是在參考Get MD5 hash of big files in Python和Hashlib in Windows and Linux 在響應於這兩個問題,建議在函數MD5使用較大的數據塊.update()來提高性能。 我所做的所有測試似乎表明使用較小的塊可以獲得最佳性能。 考慮下面的代碼: def test(factor):
filehash = hashlib.md5()