简体   繁体   English

我已经编写了自己的javascript bencode库,但仍然无法生成种子信息哈希?

[英]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.

相关问题 为什么我的 javascript 不能重定向以下代码,我尝试了多种解决方案,我在 StackOverFlow 中找到了 - Why can't my javascript redirect the following code, I've tried multiple solution that i found in StackOverFlow 如何从我自己的库中的第三方 JavaScript 库中导出所有内容? - How can I export everything from a third party JavaScript library in my own library? 我已经盯着我的代码几个小时了,找不到它出了什么问题。 -Javascript - I've been staring at my code for hours and can't find whats wrong with it. - Javascript 为什么我的浏览器不加载我用代码编写的内容? - Why won't my browser load what I've written in code? 有人可以帮我找到一个更好的替代这个Javascript for循环我写的吗? - Can someone help me find a better alternative to this Javascript for loop I've written? 如何在与html不同的文件中编写Paper.js脚本? (我按照图书馆的指示,但仍然无法正常工作) - How can I write a Paper.js script in a different file from html? (I've followed the library's instruction but it still isn't working) 我已经编写了自己的 npm 模块,当我将其导入新项目时,所有资产路径都相对于项目而不是模块内部? - I've written my own npm module, when I import it into a new project, all the asset paths are relative toward the project instead of inside the module? 如何使用Javascript编写的现有方法来验证表单? - How I can validate my form with existing method written in Javascript? 我有一个用户信息命令,并使用.createdAt在日期创建。 我不能像以前那样设计风格 - I have a user info command, and have the created at date using .createdAt. I can't stylize this as I've done previously 我有一个javascript函数,我无法分辨自己做错了什么 - I have a javascript function, and I can't tell what I've done wrong
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM