All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fisco.bcos.web3j.crypto.SHA3Digest Maven / Gradle / Ivy

There is a newer version: 2.6.6
Show newest version
package org.fisco.bcos.web3j.crypto;

import org.fisco.bcos.web3j.utils.Numeric;
import org.bouncycastle.jcajce.provider.digest.Keccak;

/**
 * Created by websterchen on 2018/3/21.
 */
public class SHA3Digest implements HashInterface {
    public SHA3Digest(){
    }
    @Override
    public String hash(String hexInput){
        byte[] bytes = Numeric.hexStringToByteArray(hexInput);
        byte[] result = hash(bytes);
        return Numeric.toHexString(result);
    }
    @Override
    public byte[] hash(byte[] input, int offset, int length){
        Keccak.DigestKeccak kecc = new Keccak.Digest256();
        kecc.update(input, offset, length);
        return kecc.digest();
    }
    @Override
    public byte[] hash(byte[] input){
        return hash(input, 0, input.length);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy