How does one calculate the info_hash parameter? Aka the hash corresponding to the info dictionar??
From official specs:
info_hash The 20 byte sha1 hash of the bencoded form of the info value from the metainfo file. Note that this is a substring of the metainfo file. This value will almost certainly have to be escaped.
Does this mean simply get the substring from the meta-info file and do a sha-1 hash on the reprezentative bytes??
.... because this is how i tried 12 times but without succes meaning I have compared the resulting hash with the one i should end up with..and they differ ..that + tracker response is FAILURE, unknown torrent ...or something
So how do you calculate the info_hash?
bdecode the metafile, then it's simply "sha1(bencode(metadata['info']))" (i.e. bencode only the info dict again, then hash that).
The metafile is already bencoded so I don't understand why you encode it again?
I finally got this working in Java code, here is my code:
This assumes the 'info' block is the last block in the torrent file (wrong?)
Don't sort or anything like that, just use a substring of the raw torrent file.
Works for me.
Visit https://gist.github.com/shxsun/9085646 , this is a python code, explains how info_generate, good luck.