Pradeep Sharma Posted June 11, 2023 Report Share Posted June 11, 2023 (edited) 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_Structure, https://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 June 11, 2023 by Pradeep Sharma Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.