org.klomp.snark.dht

## Class InfoHash

- java.lang.Object
- - net.i2p.data.SimpleDataStructure
  - - net.i2p.crypto.SHA1Hash
    - - org.klomp.snark.dht.InfoHash

- All Implemented Interfaces:
    DataStructure

      class InfoHash
      extends SHA1Hash

  Represents a BitTorrent info hash used for DHT operations.

  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.

- - ### Field Summary

    - ### Fields inherited from class net.i2p.crypto.SHA1Hash

      `HASH_LENGTH`

    - ### Fields inherited from class net.i2p.data.SimpleDataStructure

      `_data`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InfoHash(byte[] data)` Creates a new info hash from the specified 20-byte data.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `toString()` Returns a string representation of the info hash for debugging and logging.

    - ### Methods inherited from class net.i2p.crypto.SHA1Hash

      `hashCode, length, readBytes, setData`

    - ### Methods inherited from class net.i2p.data.SimpleDataStructure

      `calculateHash, equals, fromBase64, fromByteArray, getData, read, toBase64, toByteArray, writeBytes`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### InfoHash

          public InfoHash(byte[] data)

      Creates a new info hash from the specified 20-byte data.
      Parameters:
        `data` - the 20-byte SHA1 hash data representing the torrent info hash

  - ### Method Detail

    - #### toString

          public String toString()

      Returns a string representation of the info hash for debugging and logging.

      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.

      Overrides:
        `toString` in class `SimpleDataStructure`
      Returns:
        a formatted string containing the info hash in hexadecimal format