从 ruby 中的 Torrent 文件中提取哈希值
我希望提取 torrent 文件的哈希标识符。
特别是,我正在寻找打开 torrent 信息对话时 Transmission/uTorrent 中显示的相同哈希值(看起来像这样:7b435a6f051dec092a6ee440d793bfed6696cfa1)
我认为它是信息字典中的 SHA1 哈希值在 torrent 文件上。如果我将二进制文件数据从一个字节解析到另一个字节,然后执行 SHA1 哈希加密,我就可以得到它。
有谁有更好的理解或有一些代码可以做到这一点?
I was hoping to extract the hash identifier for a torrent file.
Particularly, I'm looking for the same hash that shows up in Transmission/uTorrent upon opening up a torrent info dialogue (It looks like this: 7b435a6f051dec092a6ee440d793bfed6696cfa1)
I think that it's the SHA1 hash from the info dictionary on the torrent file. If I were to parse over the binary file data from one byte to another byte, then perform a SHA1 hash encryption I could get it.
Does anyone have a better understanding or have some code that could do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
使用 firecracker gem
require "firecracker"
require "bencode_ext"
require 'open-uri'
torrent = open(link).read
# Get the info_hash from torrent file
info_hash = Firecracker.hash(torrent.bdecode)
puts "Info Hash = " + info_hash
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
使用 bencode gem:
Using the bencode gem: