rndusr / torf

Python module to create, parse and edit torrent files and magnet links
GNU General Public License v3.0
179 stars 18 forks source link

Wrong hash returned #10

Closed dausruddin closed 4 years ago

dausruddin commented 4 years ago

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.

rndusr commented 4 years ago

Confirmed.

This is gonna be fun to debug...

rndusr commented 4 years ago

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.

dausruddin commented 4 years ago

Thanks a lot!