2つのコードがあり、どちらも正確に同じファイルのMD5ハッシュを計算しています。 1つはC ++で(から盗まれたhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa382380%28v=vs.85%29.aspx 、ここでコピーペーストするには長すぎます)、もう1つ1つはPythonにあります:
md5 = hashlib.md5()
f = open("file", 'rb')
while True:
data = f.read(1024)
if not data:
break
md5.update(data)
hash = md5.hexdigest()
一見すると、2つのハッシュは等しいと思われましたが、実際にはそうではありません。
987ab42efb655a62249651907daef16e
(Python) - 9874eb5a24610de1e49651907daef16e
(C++)
33ee1578f082db63f2f590ca210f419e
(Python) - 33e5802b3250a1f1e2f590ca210f419e
(C++)
では、これらの違いを引き起こす原因は何でしょうか?
一定:
Duncanのコメントに感謝します。
Okay, I think this is the data the OP is using:
33ee1578f082db63f2f590ca210f419e usr/local/games/cs2d/sfx/items/drop.wav
987ab42efb655a62249651907daef16e usr/local/games/cs2d/sfx/items/ammo.wav