List of usage examples for org.bouncycastle.crypto.digests Blake2bDigest update
public void update(byte[] message, int offset, int len)
From source file:org.apache.nifi.security.util.crypto.HashService.java
License:Apache License
private static byte[] blake2Hash(HashAlgorithm algorithm, byte[] value) { int digestLengthBytes = algorithm.getDigestBytesLength(); Blake2bDigest blake2bDigest = new Blake2bDigest(digestLengthBytes * 8); byte[] rawHash = new byte[blake2bDigest.getDigestSize()]; blake2bDigest.update(value, 0, value.length); blake2bDigest.doFinal(rawHash, 0);/*from w w w . ja v a2s .c om*/ return rawHash; }
From source file:org.apache.nifi.security.util.crypto.HashService.java
License:Apache License
private static byte[] blake2HashStreaming(HashAlgorithm algorithm, InputStream value) throws IOException { int digestLengthBytes = algorithm.getDigestBytesLength(); Blake2bDigest blake2bDigest = new Blake2bDigest(digestLengthBytes * 8); byte[] rawHash = new byte[blake2bDigest.getDigestSize()]; final byte[] buffer = new byte[BUFFER_SIZE]; int read = value.read(buffer, 0, BUFFER_SIZE); while (read > -1) { blake2bDigest.update(buffer, 0, read); read = value.read(buffer, 0, BUFFER_SIZE); }//from w ww. j a va2s .c om blake2bDigest.doFinal(rawHash, 0); return rawHash; }