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

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

Introduction

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

Prototype

public int doFinal(byte[] out, int outOff) 

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();//  w ww .j a v a2  s .com
    md.update(dataBytes, 0, dataBytes.length);
    byte[] hashedBytes = new byte[256 / 8];
    md.doFinal(hashedBytes, 0);
    String sha3Hash = ByteUtils.toHexString(hashedBytes);
    return sha3Hash;
}