|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bitcoin.x6763.crypto.digest.Hash256
public class Hash256
The Hash256
class provides methods for hashing data
with SHA-256 twice.
There are two ways this class can be used.
The first way is to use the static hash
method, which
will internally instantiate the SHA256
on
each call:
byte[] data = new String("abc").getBytes();
byte[] hash = Hash256.hash(data);
The second way is to instantiate a Hash256
object and use the hashBytes
instance method. The Hash256
object will then reuse the same SHA256
instance for each call to hashBytes
:
Hash256 hash256 = new Hash160();
byte[] data1 = new String("def").getBytes();
byte[] hash1 = hash256.hashBytes(data1);
byte[] data2 = new String("ghi").getBytes();
byte[] hash2 = hash256.hashBytes(data2);
Constructor Summary | |
---|---|
Hash256()
Creates a Hash256 digest instance. |
Method Summary | |
---|---|
static byte[] |
hash(byte[] data)
Hashes an array of bytes with the SHA-256 algorithm twice. |
byte[] |
hashBytes(byte[] data)
Hashes an array of bytes with the SHA-256 algorithm twice. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Hash256()
Method Detail |
---|
public static byte[] hash(byte[] data)
data
- the array of bytes to hash
public byte[] hashBytes(byte[] data)
data
- the array of bytes to hash
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |