Jump to content

Need help for infoHash Calculation

Recommended Posts

Hi everyone, I am working on a summer project to create a torrent client with nodejs and is stuck on how to calculate the infoHash I have read multiple article like https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structurehttps://www.bittorrent.org/beps/bep_0003.html and with what I understood I implemented a naive approach But It's not giving me the correct hash. So if you can please look my algorithm and suggest what I am not doing correctly would we a great help.



Explanation:- It's a very naive approach, First I am calculating the infoDict length by encoding the info dict that I obtained from decoding the torrent file and then I am finding the substring from the torrent file which starts with 4:infod and has length same as we calculated earlier. I also have added an offset of 12 to ignore the 4:info. I am doing all this in hex codes because of this stack overflow thread https://stackoverflow.com/questions/28348678/what-exactly-is-the-info-hash-in-a-torrent-file

But still my Info hash value is not correct I am debugging my code using the info hash provided on the link below:- https://linuxtracker.org/index.php?page=torrent-details&id=5a9ee290c86148fcd00dead9dd225848d9fd0d7a

If you want to see my complete code and check for yourself. You can use this github link(https://github.com/pradeepsh2203/bit-torrent/).

I would be really helpful If you can help me with this 

Edited by Pradeep Sharma
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...