SuprBay: The PirateBay Forum

Full Version: How do I create the magnet of a file without using the torrent app ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I calculated the SHA-1 of a downloaded file from a torrent, and that number does not match the BTIH
Please see:
https://pirates-forum.org/Thread-Generat...-from-sha1

This is my understanding. Hope I have got it right.

The Info Hash (BTIH) is that of the .torrent file (metafile).
The contents of the .torrent file itself can be found in the specification below.
https://wiki.theory.org/BitTorrentSpecif..._Structure
You can google for .torrent editor, upload a sample torrent file and view the contents.

The BTIH is the 20-byte SHA-1 digest of the final .torrent file NOT the downloaded file(s).
The .torrent has a lot more info like the trackers, filename(s), SHA-1 of the pieces of the file(s) comprising the torrent etc.
If you wish to write a standalone program, for whatever reason, it needs to do all that work which goes into the creation of .torrent file.

You should be able to get the source of free bittorrent clients depending on the programming language your are using. From that you can try to cull the necessary code.
Specifically, the Info Hash is the SHA-1 of the info dictionary part of the torrent file, which does not include the tracker announce list or comments.

To generate a magnet from a file, or collection of files, first you would have to generate the bencoded info dictionary as per this specification. The SHA-1 hash of that would be used to generate your magnet link.

All that is purely academic without having a torrent client somewhere seeding the data using a torrent file with the same info hash.