I am reading lately a lot about hash from torrents, and magnetic links, etc. But there is a question I don't understand.
I have:
Is the infohash
= hash of the file ?
If yes what if the torrent describes 6 Files to download?
If no what does it stand for?
It checks the integrity of downloaded data, also used to check whether data is corrupted or not. Each data (may be in pieces) has a hash associated with it. After downloading the hash of downloaded data is calculated and checked with info hash of torrent.
So I finally figured it out.
The “infohash” is the SHA1 Hash over the part of a torrent file that includes:
To show this a little more I took a random torrent file and used the “BEncode Editor” from Ultima to make it more clearly to me.
As you can see the the red box marked the information part of the torrent file. The torrent file includes not the Hash of the items, but the hashes of every piece.
I am sorry that this information is about a torrent that leads to a illegal movie, but i wanted to use a torrent that realy exists.
I wanted to add another example, slightly more concrete.
We start with one of the smallest .torrent
files i have:
64 34 3A 69 6E 66 6F 64 35 3A 66 69 6C 65 73 6C 64 36 3A 6C 65 6E 67 74 68 69 36 31 35 65 34 3A 70 61 74 68 6C 32 36 3A 66 72 65 65 20 61 75 64 69 6F 62 6F 6F 6B 20 76 65 72 73 69 6F 6E 2E 74 78 74 65 65 64 36 3A 6C 65 6E 67 74 68 69 33 39 33 34 31 37 65 34 3A 70 61 74 68 6C 36 31 3A 57 61 72 63 72 61 66 74 5F 20 4F 66 66 69 63 69 61 6C 20 4D 6F 76 69 65 20 4E 6F 76 65 6C 69 7A 61 74 69 6F 6E 20 62 79 20 43 68 72 69 73 74 69 65 20 47 6F 6C 64 65 6E 2E 65 70 75 62 65 65 65 34 3A 6E 61 6D 65 36 31 3A 57 61 72 63 72 61 66 74 5F 20 4F 66 66 69 63 69 61 6C 20 4D 6F 76 69 65 20 4E 6F 76 65 6C 69 7A 61 74 69 6F 6E 20 62 79 20 43 68 72 69 73 74 69 65 20 47 6F 6C 64 65 6E 20 45 50 55 42 31 32 3A 70 69 65 63 65 20 6C 65 6E 67 74 68 69 31 30 34 38 35 37 36 65 36 3A 70 69 65 63 65 73 32 30 3A 43 92 4C 22 BB 42 9E EA BD FF 66 C6 79 4C 29 E4 F9 D0 F3 B9 65 65
If we decode the BEncoding:
64 ; DICTIONARY (d) | 34 3A 69 6E 66 6F ; - 4:info | 64 ; - DICTIONARY (d) | | 35 3A 66 69 6C 65 73 ; - 5:files | | 6C ; - LIST (l) | | | 64 ; - DICTIONARY (d) | | | | 36 3A 6C 65 6E 67 74 68 ; - 6:length | | | | 69 36 31 35 65 ; - i615e | | | | 34 3A 70 61 74 68 ; - 4:path | | | | 6C ; - LIST (l) | | | | | 32 36 3A 66 72 65 65 20 61 75 ; - 26:free audiobook verison.txt | | | | | 64 69 6F 62 6F 6F 6B 20 76 65 ; | | | | | 72 73 69 6F 6E 2E 74 78 74 ; | | | | 65 ; - END (e) | | | 65 ; - END (e) | | | 64 ; - DICTIONARY (d) | | | | 36 3A 6C 65 6E 67 74 68 ; - 6:length | | | | 69 33 39 33 34 31 37 65 ; - i393417e | | | | 34 3A 70 61 74 68 ; - 4:path | | | | 6C ; - LIST (l) | | | | | 36 31 3A 57 61 72 63 72 61 66 ; - 61:Warcraft_ Official Movie Novelization by Christie Golden.epub | | | | | 74 5F 20 4F 66 66 69 63 69 61 ; | | | | | 6C 20 4D 6F 76 69 65 20 4E 6F ; | | | | | 76 65 6C 69 7A 61 74 69 6F 6E ; | | | | | 20 62 79 20 43 68 72 69 73 74 ; | | | | | 69 65 20 47 6F 6C 64 65 6E 2E ; | | | | | 65 70 75 62 ; | | | | 65 ; - END (e) | | | 65 ; - END (e) | | 65 ; - END (e) | | 34 3A 6E 61 6D 65 ; - 4:name | | 36 31 3A 57 61 72 63 72 61 66 ; - 61:Warcraft_ Official Movie Novelization by Christie Golden EPUB | | 74 5F 20 4F 66 66 69 63 69 61 ; | | 6C 20 4D 6F 76 69 65 20 4E 6F ; | | 76 65 6C 69 7A 61 74 69 6F 6E ; | | 20 62 79 20 43 68 72 69 73 74 ; | | 69 65 20 47 6F 6C 64 65 6E 20 ; | | 45 50 55 42 ; | | 31 32 3A 70 69 65 63 65 20 6C ; - 12:piece length | | 65 6E 67 74 68 ; | | 69 31 30 34 38 35 37 36 65 ; - i10485765e | | 36 3A 70 69 65 63 65 73 ; - 6:pieces | | 32 30 3A 43 92 4C 22 BB 42 9E ; - 20:43 92 4C 22 BB 42 9E EA BD FF 66 C6 79 4C 29 E4 F9 D0 F3 B9 65 65 | | EA BD FF 66 C6 79 4C 29 E4 F9 ; | | D0 F3 B9 ; | 65 ; - END (e) 65 ; - END (e)
Or, in pseudo-json:
{ info: { files: [ { length: 615, path: ["free audiobook verison.txt"] }, { length: 393417, path: ["Warcraft_ Official Movie Novelization by Christie Golden.epub"] } ], name: "Warcraft_ Official Movie Novelization by Christie Golden EPUB", "piece length": 10485765, pieces: 43 92 4C 22 BB 42 9E EA BD FF 66 C6 79 4C 29 E4 F9 D0 F3 B9 65 65 } }
The InfoHash is the SHA-1 hash of the info dictionary contents.
We want to take the SHA-1 hash of value of the info
dictionary key:
64 ; - DICTIONARY (d) | 35 3A 66 69 6C 65 73 ; - 5:files | 6C ; - LIST (l) | | 64 ; - DICTIONARY (d) | | | 36 3A 6C 65 6E 67 74 68 ; - 6:length | | | 69 36 31 35 65 ; - i615e | | | 34 3A 70 61 74 68 ; - 4:path | | | 6C ; - LIST (l) | | | | 32 36 3A 66 72 65 65 20 61 75 ; - 26:free audiobook verison.txt | | | | 64 69 6F 62 6F 6F 6B 20 76 65 ; | | | | 72 73 69 6F 6E 2E 74 78 74 ; | | | 65 ; - END (e) | | 65 ; - END (e) | | 64 ; - DICTIONARY (d) | | | 36 3A 6C 65 6E 67 74 68 ; - 6:length | | | 69 33 39 33 34 31 37 65 ; - i393417e | | | 34 3A 70 61 74 68 ; - 4:path | | | 6C ; - LIST (l) | | | | 36 31 3A 57 61 72 63 72 61 66 ; - 61:Warcraft_ Official Movie Novelization by Christie Golden.epub | | | | 74 5F 20 4F 66 66 69 63 69 61 ; | | | | 6C 20 4D 6F 76 69 65 20 4E 6F ; | | | | 76 65 6C 69 7A 61 74 69 6F 6E ; | | | | 20 62 79 20 43 68 72 69 73 74 ; | | | | 69 65 20 47 6F 6C 64 65 6E 2E ; | | | | 65 70 75 62 ; | | | 65 ; - END (e) | | 65 ; - END (e) | 65 ; - END (e) | 34 3A 6E 61 6D 65 ; - 4:name | 36 31 3A 57 61 72 63 72 61 66 ; - 61:Warcraft_ Official Movie Novelization by Christie Golden EPUB | 74 5F 20 4F 66 66 69 63 69 61 ; | 6C 20 4D 6F 76 69 65 20 4E 6F ; | 76 65 6C 69 7A 61 74 69 6F 6E ; | 20 62 79 20 43 68 72 69 73 74 ; | 69 65 20 47 6F 6C 64 65 6E 20 ; | 45 50 55 42 ; | 31 32 3A 70 69 65 63 65 20 6C ; - 12:piece length | 65 6E 67 74 68 ; | 69 31 30 34 38 35 37 36 65 ; - i10485765e | 36 3A 70 69 65 63 65 73 ; - 6:pieces | 32 30 3A 43 92 4C 22 BB 42 9E ; - 20:43 92 4C 22 BB 42 9E EA BD FF 66 C6 79 4C 29 E4 F9 D0 F3 B9 65 65 | EA BD FF 66 C6 79 4C 29 E4 F9 ; | D0 F3 B9 ; 65 ; - END (e)
We run all these bytes together:
64 35 3A 66 69 6C 65 73 6C 64 36 3A 6C 65 6E 67 74 68 69 36 31 35 65 34 3A 70 61 74 68 6C 32 36 3A 66 72 65 65 20 61 75 64 69 6F 62 6F 6F 6B 20 76 65 72 73 69 6F 6E 2E 74 78 74 65 65 64 36 3A 6C 65 6E 67 74 68 69 33 39 33 34 31 37 65 34 3A 70 61 74 68 6C 36 31 3A 57 61 72 63 72 61 66 74 5F 20 4F 66 66 69 63 69 61 6C 20 4D 6F 76 69 65 20 4E 6F 76 65 6C 69 7A 61 74 69 6F 6E 20 62 79 20 43 68 72 69 73 74 69 65 20 47 6F 6C 64 65 6E 2E 65 70 75 62 65 65 65 34 3A 6E 61 6D 65 36 31 3A 57 61 72 63 72 61 66 74 5F 20 4F 66 66 69 63 69 61 6C 20 4D 6F 76 69 65 20 4E 6F 76 65 6C 69 7A 61 74 69 6F 6E 20 62 79 20 43 68 72 69 73 74 69 65 20 47 6F 6C 64 65 6E 20 45 50 55 42 31 32 3A 70 69 65 63 65 20 6C 65 6E 67 74 68 69 31 30 34 38 35 37 36 65 36 3A 70 69 65 63 65 73 32 30 3A 43 92 4C 22 BB 42 9E EA BD FF 66 C6 79 4C 29 E4 F9 D0 F3 B9 65
And then take the SHA-1 hash to generate a 160-bit (20-byte) digest:
7EDA978ED7628595BB91C48B947F025BAE78CB77
Which is the right answer:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With