A torrent file is a small file that contains information about how to download a larger file using the BitTorrent protocol. It contains the metadata for the file, such as its name, size, and the location of the tracker that coordinates the download. When you open a torrent file with a Torrent client, the client connects to the tracker and downloads the file from other users who are sharing it.
A magnet link is a hyperlink that contains the hash code for a torrent file. It is an alternative to traditional .torrent files and offers some advantages over them that all torrent users should be aware of. A magnet link contains a unique identifier, various parameters depending on the exact nature of the torrent, and, most importantly, a cryptographic hash of the torrent files. A cryptographic hash is a mathematical algorithm applied to data that results in a short unique string that represents that data. This is useful for torrents because you can hash any two torrents and if they point to exactly the same files, they will have identical hashes. So, for your torrent client to know who else is part of a given torrent, it simply has to compare the hash in the magnet link to the hashes of torrents that are being shared. Filtering out only those with matching hashes quickly reconstructs the swarm of peers on the network. This is the same method used by the Distributed Hash Table found within “trackerless” torrents.
In summary, a torrent file is a small file that contains information about how to download a larger file using the BitTorrent protocol, while a magnet link is a hyperlink that contains the hash code for a torrent file. Magnet links offer some advantages over traditional .torrent files, such as the ability to download content even if the tracker is down or closed for registration.