开发者

How to convert 32digit long info hash to 40 digit long info hash in python? [closed]

开发者 https://www.devze.com 2023-03-10 00:42 出处:网络
It's difficult to开发者_如何学Go tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form.
It's difficult to开发者_如何学Go tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消