Code below (apologies for ugliness), I'm running this to calculate the hash for a torrent but it is giving me a different answer than when I open that torrent directly in Transmission:
I'm testing on r_000 on this page: http://gen.lib.rus.ec/repository_torrent/
Transmission gives me: 63a04291a8b266d968aa7ab8a276543fa63a9e84
My code gives me: 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)
Any idea what I've screwed up? Thanks!