[英]I've written my own javascript bencode library and I still can't generate torrent info hashes?
I've searched everywhere looking for a working JavaScript Bencode module and couldn't find one so I decided to write my own for the purpose of generating torrent info hashes. 我到处搜索以寻找可用的JavaScript Bencode模块,但找不到模块,因此我决定编写自己的模块以生成torrent信息哈希。
The module works to the best of my knowledge as I wrote the functions to the specification. 在我按照规范编写功能时,该模块已尽我所知。
Dictionary => Objects => Key/value pairs 字典=>对象=>键/值对
List => Array Objects => number/value pairs 列表=>数组对象=>数字/值对
Integers => Number Objects 整数=>数字对象
Strings... 弦...
Anyway, I decode the torrent file's data and then encode the decoded info key's value, next I use a SHA-1 module by Google API and the info hash never matches the original. 无论如何,我先解码torrent文件的数据,然后再对解码后的信息密钥的值进行编码,然后我使用Google API的SHA-1模块,并且信息哈希值与原始哈希值不匹配。 I'm dumb founded.
我很笨。
I've tested my module thoroughly. 我已经对模块进行了彻底的测试。 I can decode the data pass it to my encode function and its and exact match to the original data but when I try to generate the hash from the encoded info section value I get a mismatch.
我可以对数据进行解码,然后将其传递给我的编码函数,并将其与原始数据完全匹配,但是当我尝试从编码的信息节值生成哈希时,会出现不匹配的情况。
I do believe this is due to JavaScript's poor binary string handling and I have no idea how to diagnose or resolve this issue. 我确实认为这是由于JavaScript的二进制字符串处理不当所致,而且我不知道如何诊断或解决此问题。
When I output the data from a get request depending on the content-type header the binary portion of the string displays differently and is the reason I've come to this conclusion. 当我根据内容类型标头从get请求输出数据时,字符串的二进制部分显示的方式有所不同,这就是得出此结论的原因。
I understand that the torrent file is UTF-8 character encoded but after that I'm helpless... 我知道种子文件是UTF-8字符编码的,但此后我就束手无策了...
Thanks for any help in advance. 感谢您的任何帮助。
The torrent file is UTF-8 character encoded but parts of it are not. 种子文件使用UTF-8字符编码,但部分文件未编码。 The "pieces" key in the info dictionary is strictly ASCII encoded, retrieving it as UTF-8 causes errors for me with [C] and will probably do the same to you with JavaScript.
信息字典中的“件”键完全是ASCII编码的,因为UTF-8用[C]对我来说会引起错误,因此可能会用JavaScript对其执行相同的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.