Java Code Examples for org.spongycastle.crypto.Digest#doFinal()

The following examples show how to use org.spongycastle.crypto.Digest#doFinal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HashUtil.java    From wkcwallet-java with Apache License 2.0 5 votes vote down vote up
/**
 * @param data - message to hash
 * @return - reipmd160 hash of the message
 */
public static byte[] ripemd160(byte[] data) {
    Digest digest = new RIPEMD160Digest();
    if (data != null) {
        byte[] resBuf = new byte[digest.getDigestSize()];
        digest.update(data, 0, data.length);
        digest.doFinal(resBuf, 0);
        return resBuf;
    }
    throw new NullPointerException("Can't hash a NULL value");
}
 
Example 2
Source File: HashUtil.java    From asf-sdk with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param data - message to hash
 *
 * @return - reipmd160 hash of the message
 */
public static byte[] ripemd160(byte[] data) {
  Digest digest = new RIPEMD160Digest();
  if (data != null) {
    byte[] resBuf = new byte[digest.getDigestSize()];
    digest.update(data, 0, data.length);
    digest.doFinal(resBuf, 0);
    return resBuf;
  }
  throw new NullPointerException("Can't hash a NULL value");
}
 
Example 3
Source File: Sha3Hash.java    From nuls with MIT License 5 votes vote down vote up
public static String sha3(byte[] bytes, int bitLength) {
    Digest digest = new SHA3Digest(bitLength);
    digest.update(bytes, 0, bytes.length);
    byte[] rsData = new byte[digest.getDigestSize()];
    digest.doFinal(rsData, 0);
    return Hex.encode(rsData);
}
 
Example 4
Source File: Sha3Hash.java    From nuls with MIT License 5 votes vote down vote up
public static byte[] sha3bytes(byte[] bytes, int bitLength) {
    Digest digest = new SHA3Digest(bitLength);
    digest.update(bytes, 0, bytes.length);
    byte[] rsData = new byte[digest.getDigestSize()];
    digest.doFinal(rsData, 0);
    return rsData;
}
 
Example 5
Source File: KeccakHash.java    From nuls with MIT License 5 votes vote down vote up
public static String keccak(byte[] bytes, int bitLength) {
    Digest digest = new KeccakDigest(bitLength);
    digest.update(bytes, 0, bytes.length);
    byte[] rsData = new byte[digest.getDigestSize()];
    digest.doFinal(rsData, 0);
    return Hex.encode(rsData);
}
 
Example 6
Source File: KeccakHash.java    From nuls with MIT License 5 votes vote down vote up
public static byte[] keccakBytes(byte[] bytes, int bitLength) {
    Digest digest = new KeccakDigest(bitLength);
    digest.update(bytes, 0, bytes.length);
    byte[] rsData = new byte[digest.getDigestSize()];
    digest.doFinal(rsData, 0);
    return rsData;
}
 
Example 7
Source File: HashUtil.java    From nuls with MIT License 5 votes vote down vote up
/**
 * @param data - message to hash
 * @return - reipmd160 hash of the message
 */
public static byte[] ripemd160(byte[] data) {
    Digest digest = new RIPEMD160Digest();
    if (data != null) {
        byte[] resBuf = new byte[digest.getDigestSize()];
        digest.update(data, 0, data.length);
        digest.doFinal(resBuf, 0);
        return resBuf;
    }
    throw new NullPointerException("Can't hash a NULL value");
}