How to convert 32digit long info hash to 40 digit long info hash in python? [closed]
Some websites such as Sumotorrent.com use the magnet link with the 32 digit long hash, but my code is designed to store and work with 40 digit long hash?
The info hash in those magnet links appear to be encoded in Base32, while the info hash used in bittorrent is in hexadecimal (i.e. Base16). This appears to give consistent results:
import base64
base64.b16encode(base64.b32decode("<your hash goes here>"))
Luckily 32 is smaller than 40, so you can just pad with 8 zeroes without losing information.
精彩评论