简体   繁体   English

从Erlang种子文件中的信息字典中获取SHA哈希

[英]Getting the SHA hash from info dictionary in torrent file in Erlang

I have been trying to parse a torrent file in Erlang, So far I was able to extract all the general info like torrent name, files(length, path, name), tracker link... 我一直试图在Erlang中解析一个种子文件,到目前为止,我能够提取所有常规信息,例如种子名称,文件(长度,路径,名称),跟踪链接。

The only thing that is bothering me is the sha1 hash value. 唯一困扰我的是sha1哈希值。 I checked many websites online and according to the specification the "info" dictionary is what needs to be hashed. 我在网上检查了许多网站,根据规范,“信息”字典是需要进行哈希处理的内容。 However, I'm still confused by the delimiters. 但是,我仍然对定界符感到困惑。 Should d and e be included or not? 是否应包含d和e?

Finally, I think that it matters how the data is read in from the file, right now I read the file as a binary then convert it to a list before parsing the data. 最后,我认为如何从文件中读取数据很重要,现在我以二进制文件形式读取文件,然后在解析数据之前将其转换为列表。 Does this change/corrupt the hash if generated? 如果生成哈希表,是否会更改/破坏哈希表? Is there a suitable data type (Binary / List) to be able to correctly extract the info dictionary. 是否有合适的数据类型(二进制/列表)以能够正确提取信息字典。

Thanks in advance. 提前致谢。

I´m not sure I understood exactly what you want, but i´m not an torrent file expert. 我不确定我确切了解您想要什么,但我不是洪流文件专家。 For getting the SHA1 from a binary: http://www.erlang.org/doc/man/crypto.html 要从二进制文件获取SHA1: http//www.erlang.org/doc/man/crypto.html

if you need SHA2: http://steve.vinoski.net/code/sha2.html 如果您需要SHA2: http ://steve.vinoski.net/code/sha2.html

Everything from the info dictionary should be hashed including the first and last characters; 信息字典中的所有内容都应进行哈希处理,包括第一个和最后一个字符; the d and e. d和e。

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

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