Package org.web3j.crypto
Class Hash
java.lang.Object
org.web3j.crypto.Hash
Cryptographic hash functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]blake2b256(byte[] input) Blake2-256 hash function.static byte[]Generates a digest for the giveninput.static byte[]hmacSha512(byte[] key, byte[] input) static byte[]sha256(byte[] input) Generates SHA-256 digest for the giveninput.static byte[]sha256hash160(byte[] input) static byte[]sha3(byte[] input) Keccak-256 hash function.static byte[]sha3(byte[] input, int offset, int length) Keccak-256 hash function.static StringKeccak-256 hash function.static Stringsha3String(String utf8String) Keccak-256 hash function that operates on a UTF-8 encoded String.
-
Method Details
-
hash
Generates a digest for the giveninput.- Parameters:
input- The input to digestalgorithm- The hash algorithm to use- Returns:
- The hash value for the given input
- Throws:
RuntimeException- If we couldn't find any provider for the given algorithm
-
sha3
Keccak-256 hash function.- Parameters:
hexInput- hex encoded input data with optional 0x prefix- Returns:
- hash value as hex encoded string
-
sha3
public static byte[] sha3(byte[] input, int offset, int length) Keccak-256 hash function.- Parameters:
input- binary encoded input dataoffset- of start of datalength- of data- Returns:
- hash value
-
sha3
public static byte[] sha3(byte[] input) Keccak-256 hash function.- Parameters:
input- binary encoded input data- Returns:
- hash value
-
sha3String
Keccak-256 hash function that operates on a UTF-8 encoded String.- Parameters:
utf8String- UTF-8 encoded string- Returns:
- hash value as hex encoded string
-
sha256
public static byte[] sha256(byte[] input) Generates SHA-256 digest for the giveninput.- Parameters:
input- The input to digest- Returns:
- The hash value for the given input
- Throws:
RuntimeException- If we couldn't find any SHA-256 provider
-
hmacSha512
public static byte[] hmacSha512(byte[] key, byte[] input) -
sha256hash160
public static byte[] sha256hash160(byte[] input) -
blake2b256
public static byte[] blake2b256(byte[] input) Blake2-256 hash function.- Parameters:
input- binary encoded input data- Returns:
- hash value
-