rndusr / torf

Python module to create, parse and edit torrent files and magnet links

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong hash returned

dausruddin opened this issue · comments

Hi. I have been testing multiple torrent and suddenly 1 of the torrents returning a wrong hash.

Manjaro%20Kde%2015.12%20x86_64.zip (or download from here)

If I added in qbittorrent, the hash registered is db4d75e4f9e846e641d043a36f73187bb364c111.
But somehow in torf, hash returned is 1925c683d9fe4156b8e4be0a193a157acd6582ed.
image

This is the code I am using

#!/usr/bin/env python3.8

from torf import Torrent
import json
import sys

if len(sys.argv) == 2:
    try:
        torrent = Torrent.read(sys.argv[1])
        torrentlist = {'hash': torrent.infohash, 'files': list(torrent.files)}
        print(json.dumps(torrentlist))
    except Exception as e:
        print(e)
else:
    print('No .torrent detected')

I am running the latest code.

Fixed.

It was easier than I thought. The Torrent.private property removed the 'private'
field from metainfo['info'] when it was set to False. This changes the info hash
because it is created with sha1(metainfo['info']).

Now the 'private' field can only be removed by setting the private property to
None.

Thanks a lot!