Created
September 10, 2009 05:07
-
-
Save nbrochu/184324 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generating the info_hash from a torrent file (binary & urlencoded) | |
require 'bencode' # sudo gem install bencode | |
require 'digest/sha1' | |
require 'cgi' # Not needed in rails | |
decoded_torrent = BEncode.load_file("public/files/example.torrent") | |
info_hash = ([Digest::SHA1.hexdigest(decoded_torrent["info"].bencode)].pack("H*")).downcase | |
url_encoded_info_hash = CGI.escape(info_hash) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment