content = BEncode.load(file) info_bencoded = content['info'].bencode info_hash = Digest::SHA1.digest(info_bencoded) info_hash32 = Base32.encode(info_hash) info_hash32_escaped = URI.encode(info_hash32) puts "magnet:?xt=urn:btih:#{info_hash32_escaped}"
This code requires bencode and base32 gems.
No comments:
Post a Comment