com.syntifi.crypto.key.hash.Blake2b Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of casper-java-sdk Show documentation
Show all versions of casper-java-sdk Show documentation
SDK to streamline the 3rd party Java client integration processes. Such 3rd parties include exchanges & app developers.
The newest version!
package com.syntifi.crypto.key.hash;
import org.bouncycastle.crypto.digests.Blake2bDigest;
/**
* Blake2 Hash helper class
*
* @author Alexandre Carvalho
* @author Andre Bertolace
* @since 0.2.0
*/
public class Blake2b {
/**
* returns a Blake2b Hash of size length in bytes
*
* @param input byte array to hash
* @param length desired output length in bytes
* @return a byte array of size 'length' bytes
*/
public static byte[] digest(byte[] input, int length) {
Blake2bDigest d = new Blake2bDigest(length * 8);
d.update(input, 0, input.length);
byte[] result = new byte[d.getDigestSize()];
d.doFinal(result, 0);
return result;
}
}