org.bitcoin.x6763.crypto.digest
Class Hash160

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

public class Hash160
extends java.lang.Object

The Hash160 class provides methods for hashing data first with SHA-256, and feeding that result into the RIPEMD-160 hash.

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 and RIPEMD160 classes on each call:

 byte[] data = new String("abc").getBytes();
 byte[] hash = Hash160.hash(data);
 
 
The second way is to instantiate a Hash160 object and use the hashBytes instance method. The Hash160 object will then reuse the same SHA256 and RIPEMD160 objects for each call to hashBytes:
 Hash160 hash160 = new Hash160();
 
 byte[] data1 = new String("def").getBytes();
 byte[] hash1 = hash160.hashBytes(data1);
 
 byte[] data2 = new String("ghi").getBytes();
 byte[] hash2 = hash160.hashBytes(data2);
 
 

Author:
x6763

Constructor Summary
Hash160()
          Creates a Hash160 digest instance.
 
Method Summary
static byte[] hash(byte[] data)
          Hashes an array of bytes with the SHA-256 algorithm, followed by the RIPEMD-160 algorithm.
 byte[] hashBytes(byte[] data)
          Hashes an array of bytes with the SHA-256 algorithm, followed by the RIPEMD-160 algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hash160

public Hash160()
Creates a Hash160 digest instance.

Method Detail

hash

public static byte[] hash(byte[] data)
Hashes an array of bytes with the SHA-256 algorithm, followed by the RIPEMD-160 algorithm.

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, followed by the RIPEMD-160 algorithm.

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