Class Sha1Hash
java.lang.Object
com.frostwire.jlibtorrent.Sha1Hash
- All Implemented Interfaces:
Cloneable,Comparable<Sha1Hash>
This type holds a SHA-1 digest or any other kind of 20 byte
sequence. It implements a number of convenience functions, such
as bit operations, comparison operators etc.
In libtorrent it is primarily used to hold info-hashes, piece-hashes, peer IDs, node IDs etc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()set the sha1-hash to all zeroes.clone()intintbooleaninthashCode()booleanreturn true if the sha1-hash is all zero.static Sha1Hashmax()returns an all-F sha1-hash.static Sha1Hashmin()returns an all-zero sha1-hash.swig()toHex()Returns the hex representation of this has.toString()Returns an hex representation of this hash.
-
Constructor Details
-
Sha1Hash
- Parameters:
h- native object
-
Sha1Hash
public Sha1Hash(byte[] bytes) - Parameters:
bytes- hash as an array of bytes
-
Sha1Hash
- Parameters:
hex- hex coded representation of the hash
-
Sha1Hash
public Sha1Hash()Constructs an all-zero sha1-hash
-
-
Method Details
-
swig
- Returns:
- the native object
-
clear
public void clear()set the sha1-hash to all zeroes. -
isAllZeros
public boolean isAllZeros()return true if the sha1-hash is all zero.- Returns:
- true if zero
-
countLeadingZeroes
public int countLeadingZeroes()- Returns:
- the number of leading zeroes
-
toHex
Returns the hex representation of this has.This method uses internally the libtorrent to_hex function.
- Returns:
- the hex representation
-
compareTo
- Specified by:
compareToin interfaceComparable<Sha1Hash>- Parameters:
o-- Returns:
-
toString
-
equals
-
hashCode
-
clone
-
max
returns an all-F sha1-hash. i.e. the maximum value representable by a 160 bit number (20 bytes). This is a static member function.- Returns:
- the maximum number
-
min
returns an all-zero sha1-hash. i.e. the minimum value representable by a 160 bit number (20 bytes). This is a static member function.- Returns:
- the minimum number (zero)
-