org.bitcoin.x6763.crypto.digest
Class Hash256

java.lang.Object
  extended by org.bitcoin.x6763.crypto.digest.Hash256

public class Hash256
extends java.lang.Object

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);
 
 

Author:
x6763

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

Hash256

public Hash256()
Creates a Hash256 digest instance.

Method Detail

hash

public static byte[] hash(byte[] data)
Hashes an array of bytes with the SHA-256 algorithm twice.

Parameters:
data - the array of bytes to hash
Returns:
the array of bytes for the resulting hash value

hashBytes

public byte[] hashBytes(byte[] data)
Hashes an array of bytes with the SHA-256 algorithm twice.

Parameters:
data - the array of bytes to hash
Returns:
the array of bytes for the resulting hash value