|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.bitcoin.core.Sha256Hash
public class Sha256Hash
A Sha256Hash just wraps a byte[] so that equals and hashcode work correctly, allowing it to be used as keys in a map. It also checks that the length is correct and provides a bit more type safety.
| Field Summary | |
|---|---|
static Sha256Hash |
ZERO_HASH
|
| Constructor Summary | |
|---|---|
Sha256Hash(byte[] rawHashBytes)
Creates a Sha256Hash by wrapping the given byte array. |
|
Sha256Hash(String hexString)
Creates a Sha256Hash by decoding the given hex string. |
|
| Method Summary | |
|---|---|
int |
compareTo(Object o)
|
static Sha256Hash |
create(byte[] contents)
Calculates the (one-time) hash of contents and returns it as a new wrapped hash. |
static Sha256Hash |
createDouble(byte[] contents)
Calculates the hash of the hash of the contents. |
Sha256Hash |
duplicate()
|
boolean |
equals(Object other)
Returns true if the hashes are equal. |
byte[] |
getBytes()
|
int |
hashCode()
Hash code of the byte array as calculated by Object.hashCode(). |
static Sha256Hash |
hashFileContents(File f)
Returns a hash of the given files contents. |
BigInteger |
toBigInteger()
Returns the bytes interpreted as a positive integer. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Sha256Hash ZERO_HASH
| Constructor Detail |
|---|
public Sha256Hash(byte[] rawHashBytes)
public Sha256Hash(String hexString)
| Method Detail |
|---|
public static Sha256Hash create(byte[] contents)
public static Sha256Hash createDouble(byte[] contents)
public static Sha256Hash hashFileContents(File f)
throws IOException
IOExceptionpublic boolean equals(Object other)
equals in class Objectpublic int hashCode()
Object.hashCode(). Note the difference between a SHA256
secure bytes and the type of quick/dirty bytes used by the Java hashCode method which is designed for use in
bytes tables.
hashCode in class Objectpublic String toString()
toString in class Objectpublic BigInteger toBigInteger()
public byte[] getBytes()
public Sha256Hash duplicate()
public int compareTo(Object o)
compareTo in interface Comparable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||