public class Hash
extends java.lang.Object
| 限定符 | 构造器和说明 |
|---|---|
|
Hash(byte[] hash)
create a Hash from a digest
|
protected |
Hash(byte[] hash,
boolean safe)
An unsafe constructor of a Hash from a byte array.
|
|
Hash(java.lang.String hex)
create a Hash from a hexadecimal representation of the digest
Note that this is in the reverse byte order of the internal binary representation.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static Hash |
createFromSafeArray(byte[] hash)
Unsafe constructor of a Hash.
|
boolean |
equals(java.lang.Object o) |
static byte[] |
hash(byte[] data)
SHA256 hash of arbitrary data
|
static byte[] |
hash(byte[] data,
int offset,
int len)
SHA256 hash of arbitrary data
|
int |
hashCode() |
static Hash |
merge(Hash a,
Hash b)
Merge two Hashes into one for Merkle Tree calculation
|
static Hash |
of(byte[] data)
Create a Hash with double SHA256 hash of arbitrary data
|
java.math.BigInteger |
toBigInteger()
Convert a Hash into a big positive integer.
|
byte[] |
toByteArray()
Safe access to the digest stored in a Hash
|
java.lang.String |
toString() |
java.lang.String |
toUuidString()
UUID created from the first 128 bits of SHA256
|
byte[] |
unsafeGetArray()
Unsafe get of the internal byte array.
|
public static final Hash INVALID
public Hash(byte[] hash)
hash - - digest must be 32 bytes longpublic Hash(java.lang.String hex)
hex - - a digest as a 64 character hexadecimal sequence in reverse byte order.protected Hash(byte[] hash,
boolean safe)
hash - - a 32 byte digestsafe - - a dummy paramater to distinguish this unsafe constructor from the safe one.public byte[] unsafeGetArray()
public static Hash createFromSafeArray(byte[] hash)
hash - a digest. DO NOT ALTER the array after creating a Hash with it.public static Hash merge(Hash a, Hash b)
a - - a Hashb - - another Hashpublic static byte[] hash(byte[] data,
int offset,
int len)
data - arbitary dataoffset - start hashing at this offset (0 starts)len - hash len number of bytespublic static byte[] hash(byte[] data)
data - arbitrary datapublic static Hash of(byte[] data)
data - arbitrary datapublic java.lang.String toUuidString()
public byte[] toByteArray()
public java.math.BigInteger toBigInteger()
public java.lang.String toString()
toString 在类中 java.lang.Objectpublic int hashCode()
hashCode 在类中 java.lang.Objectpublic boolean equals(java.lang.Object o)
equals 在类中 java.lang.ObjectCopyright © 2018. All Rights Reserved.