简体   繁体   English

Sha 1散列及其使用bit torrent协议(磁铁)的长度?

[英]Sha 1 hashes and their length with the bit torrent protocol (magnets)?

I am scraping websites for information and it involves getting sha1 hashes of magnet links. 我正在抓取网站上的信息,它涉及获取磁铁链接的sha1哈希。

I get all the magnet links with a simple preg_match_all but in my results I am getting weird results, I understand that a magnet hash in its hexadecimal form is 40 characters long, but I am also getting results that return strings that are 32 characters long that contain other non hexadecimal values. 我用一个简单的preg_match_all得到了所有磁链,但是在结果中我得到了奇怪的结果,我知道磁石哈希以十六进制形式是40个字符长,但是我也得到了返回长度为32个字符的字符串的结果。包含其他非十六进制值。

Two examples from my results, firstly a normal 40 hexadecimal hash within a magnet link, 我的结果有两个例子,首先是磁链中的正常40十六进制哈希,

array
    0 => string 'F5AD2D170C033736FD987106F04C3ABD6DF41D14' (length=40)

And the other weird results that I do not understand where the hash is a 32 non hexadecimal value, 我不明白哈希在哪里是32个非十六进制值的其他奇怪结果,

array
    0 => string 'VPR33QQM3L6BFU5FGOZXMBNORAFFSZWW' (length=32)

Has the hash been packed in some way? 哈希是否以某种方式打包? I know it is not done with pack('H*', $hash) as that returns the binary of the hash? 我知道这不是用pack('H*', $hash)因为它返回哈希的二进制? The magnet links do work as I have tested them. 磁铁链接确实可以正常工作。

More so you can see these hashes in use at this website 更多信息,因此您可以在此网站上看到这些哈希在使用中

http://eztv.it http://eztv.it

By hovering over the magnet links and looking a the magnet hash. 通过将鼠标悬停在磁铁链上并查找磁铁哈希。

Thanks 谢谢

Hashes in magnet links can be encoded using Base32 . 可以使用Base32对磁铁链接中的哈希进行编码。 In your example, 在您的示例中

VPR33QQM3L6BFU5FGOZXMBNORAFFSZWW

turns into 变成

ABE3BDC20CDAFC12D3A533B37605AE880A5966D6

which is a valid SHA-1 hash. 这是有效的SHA-1哈希。

Basically its not a valid torrent info hash, only sha1 (40 bytes) are valid, a torrent client or bencode script would fail if you passed that as a torrent hash. 基本上,它不是有效的torrent信息哈希,只有sha1(40个字节)有效,如果将torrent客户端或bencode脚本作为torrent哈希传递,则torrent客户端或bencode脚本将失败。

It seems its related to: 似乎与以下内容有关:

http://eztv.it/magnet:?xt=urn:btih:VPR33QQM3L6BFU5FGOZXMBNORAFFSZWW Which is noting. http://eztv.it/magnet:?xt=urn:btih:VPR33QQM3L6BFU5FGOZXMBNORAFFSZWW这值得注意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM