Class Sha256Hash

java.lang.Object
com.frostwire.jlibtorrent.Sha256Hash
All Implemented Interfaces:
Cloneable, Comparable<Sha256Hash>

public final class Sha256Hash extends Object implements Comparable<Sha256Hash>, Cloneable
SHA-256 digest or any other kind of 32 byte sequence.
  • Constructor Details

    • Sha256Hash

      public Sha256Hash(sha256_hash h)
      Parameters:
      h - native object
    • Sha256Hash

      public Sha256Hash()
      Constructs an all-zero sha256-hash
    • Sha256Hash

      public Sha256Hash(byte[] bytes)
      Parameters:
      bytes - hash as an array of bytes
    • Sha256Hash

      public Sha256Hash(String hex)
      Parameters:
      hex - hex coded representation of the hash
  • Method Details

    • clear

      public void clear()
      set the sha256-hash to all zeroes.
    • isAllZeros

      public boolean isAllZeros()
      return true if the sha256-hash is all zero.
      Returns:
      true if zero
    • countLeadingZeroes

      public int countLeadingZeroes()
      Returns:
      the number of leading zeroes
    • toHex

      public String toHex()
      Returns the hex representation of this has.

      This method uses internally the libtorrent to_hex function.

      Returns:
      the hex representation
    • compareTo

      public int compareTo(Sha256Hash o)
      Specified by:
      compareTo in interface Comparable<Sha256Hash>
      Parameters:
      o -
      Returns:
    • toString

      public String toString()
      Returns an hex representation of this hash. Internally it calls toHex().
      Overrides:
      toString in class Object
      Returns:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      Parameters:
      obj -
      Returns:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
    • clone

      public Sha256Hash clone()
      Overrides:
      clone in class Object
    • max

      public static Sha256Hash max()
      returns an all-F sha256-hash. i.e. the maximum value representable by a 256 bit number (32 bytes). This is a static member function.
      Returns:
      the maximum number
    • min

      public static Sha256Hash min()
      returns an all-zero sha256-hash. i.e. the minimum value representable by a 256 bit number (32 bytes). This is a static member function.
      Returns:
      the minimum number (zero)
    • swig

      public sha256_hash swig()