The only complicated part of this code is handling multi-file torrents because a single torrent piece can span more than one file (internally BitTorrent treats multi-file downloads as a single contiguous file). These hashes are then compared with the hash of the pieces of on-disk file(s). That string contains a succession of 20 byte hashes (one for each piece). Metainfo = bencode.bdecode(torrent_file.read()) The code takes the hashes contained in the info string: torrent_file = open(sys.argv, "rb") It can marshal lists, dictionaries, strings and numbers somewhat like JSON. Bencode is the serialization format used in. You need the bencode package to use this. Assuming you want to check a download for corruption you may find this useful. I wrote a piece of python code that verifies the hashes of downloaded files against what's in a.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |