English 中文(简体)
从Erlang中torrent文件中的信息字典中获取SHA哈希
原标题:Getting the SHA hash from info dictionary in torrent file in Erlang

我一直在尝试在Erlang中解析torrent文件,到目前为止,我能够提取所有的一般信息,如torrent名称、文件(长度、路径、名称)、跟踪器链接。。。

The only thing that is bothering me is the sha1 hash value. 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。

问题回答

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

if you need SHA2: http://steve.vinoski.net/code/sha2.html





相关问题
How big can Erlang DETS be and what to do if its too small?

All I need is a large persistent lookup table in Erlang and dets seems like just the thing though I need a definative answer to: just how big the total size of the binaries in the table can be. how ...

passing events from erlang to Clojure

I m looking for a way to pass events back and forth between Clojure and erlang. has someone done this before? how should I encode the (immutable) messages in a flaxable general way? Should IPC be ...

How to send a push notification using Erlang?

I m trying to send a push notification to APNs using Erlang. This is the code I came up with so far: -module(apnstest2). -export([connect/0]). connect() -> application:start(ssl), ssl:...

How do I build a DNS Query record in Erlang?

I am building a native Bonjour / Zeroconf library and need to build DNS query records to broadcast off to the other machines. I have tried looking thru the Erlang source code but as I am relatively ...

AccessViolation when calling unmanaged dll

When calling an unmanaged Dll from a c# application I get an AccessViolationException. The strange thing is that the exported function has no arguments, so the problem is not in the Marshalling of ...

How to enable active sockets in a Mochiweb application?

Does anyone know how to enable active instead of passive sockets in a Mochiweb application. Specifically, I am trying to adapt http://www.metabrew.com/article/a-million-user-comet-application-with-...

How to convert numbers to words in Erlang?

I found this interesting question about converting numbers into "words": Code Golf: Number to Words I would really like to see how you would implement this efficiently in Erlang.

热门标签