Bittorrent KRPC - Why are node ID's half the size of an info_hash and use every character a-z?

随声附和 提交于 2019-12-11 04:58:38

问题


This has seriously perplexed me.

The original Kademlia offers that 160bit hex like a sha1 should be used for obvious reasons: When searching for peers relating to an infohash, you simple search nodeIDs as they should be equivalent to the same system as the sha1 infohash.

But reading this: http://www.bittorrent.org/beps/bep_0005.html

the id's are abcdefghi0123456789 which is: 1) Half the size 2) Uses more characters then standard hex encoding.

So what am I missing?

Why are node id's like this?


回答1:


To make the raw binary node_id in the examples printable,
it has cleverly been chosen to consist of only alphanumeric characters.
The node_id in the examples are actually: abcdefghij0123456789
As you can see there are 20 characters = 20 bytes = 160 bits as expected.

abcdefghij0123456789 hex-encoded is: 0x6162636465666768696A30313233343536373839



来源:https://stackoverflow.com/questions/42143107/bittorrent-krpc-why-are-node-ids-half-the-size-of-an-info-hash-and-use-every

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!