Example usage for org.bouncycastle.crypto.digests SHA3Digest update

List of usage examples for org.bouncycastle.crypto.digests SHA3Digest update

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.digests SHA3Digest update.

Prototype

public void update(byte[] in, int inOff, int len) 

Source Link

Usage

From source file:org.thingsboard.server.common.msg.EncryptionUtil.java

License:Apache License

public static String getSha3Hash(String data) {
    String trimmedData = trimNewLines(data);
    byte[] dataBytes = trimmedData.getBytes();
    SHA3Digest md = new SHA3Digest(256);
    md.reset();/*from   w w  w.ja v a2s.  co  m*/
    md.update(dataBytes, 0, dataBytes.length);
    byte[] hashedBytes = new byte[256 / 8];
    md.doFinal(hashedBytes, 0);
    String sha3Hash = ByteUtils.toHexString(hashedBytes);
    return sha3Hash;
}