class InfoHash extends SHA1Hash
An info hash is a 20-byte SHA1 hash that uniquely identifies a torrent. In the DHT context, info hashes are used as keys to locate peers and track torrent participation across the distributed network.
Info hashes serve as the primary identifier for DHT operations:
- get_peer requests use info hashes to find peers for specific torrents
- announce_peer requests associate peers with specific info hashes
- DHT routing uses info hashes to determine which nodes should store peer information
This class extends SHA1Hash to provide torrent-specific functionality and formatting for debugging and logging purposes.
HASH_LENGTH_data| Constructor and Description |
|---|
InfoHash(byte[] data)
Creates a new info hash from the specified 20-byte data.
|
| Modifier and Type | Method and Description |
|---|---|
String |
toString()
Returns a string representation of the info hash for debugging and logging.
|
calculateHash, equals, fromBase64, fromByteArray, getData, read, toBase64, toByteArray, writeBytespublic InfoHash(byte[] data)
data - the 20-byte SHA1 hash data representing the torrent info hashpublic String toString()
Formats the info hash as hexadecimal within brackets for easy identification in log files and debug output. This provides a more readable representation than the default SHA1Hash toString() method.
toString in class SimpleDataStructure