下面的代码(对丑陋表示歉意),我运行它来计算 torrent 的哈希值,但它给出的答案与我直接在 Transmission 中打开该 torrent 时不同:
我正在此页面上的 r_000 上进行测试:http://gen.lib.rus.ec/repository_torrent/
传输给我:63a04291a8b266d968aa7ab8a276543fa63a9e84
我的代码给了我:1882ff6534ee4aa660e2fbf225c1796638bea4c0
import bencoding
from io import BytesIO
import binascii
import hashlib
with open("cache/r_000.torrent", "rb") as f:
data = bencoding.bdecode(f.read())
info = data[b'info']
hashed_info = hashlib.sha1(info[b'pieces']).hexdigest()
print(hashed_info)
Run Code Online (Sandbox Code Playgroud)
知道我搞砸了什么吗?谢谢!