Package sg.dex.crypto
Class Hash
- java.lang.Object
-
- sg.dex.crypto.Hash
-
public class Hash extends Object
Utility class for hash functions- Author:
- Mike
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]
EMPTY_BYTES_SHA3
-
Constructor Summary
Constructors Constructor Description Hash()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
keccak256(byte[] data)
Compute the Keccak256 hash of a byte arraystatic byte[]
keccak256(byte[] data, int offset, int length)
Compute the Keccak256 hash of byte array segmentstatic byte[]
keccak256(String string)
Compute the Keccak256 hash of string, with UTF-8 encodingstatic String
keccak256String(byte[] data)
Compute the Keccak256 hash of byte arraystatic String
keccak256String(String string)
Compute the Keccak256 hash of string, with UTF-8 encodingstatic byte[]
sha3_256(byte[] data)
Compute the SHA3-256 hash of a byte arraystatic byte[]
sha3_256(byte[] data, int offset, int length)
Compute the SHA3-256 hash of byte array segmentstatic byte[]
sha3_256(String string)
Compute the SHA3-256 hash of string, with UTF-8 encodingstatic String
sha3_256String(byte[] data)
Compute the sha3_256 hash of byte arraystatic String
sha3_256String(String string)
Compute the sha3_256 hash of string, with UTF-8 encoding
-
-
-
Method Detail
-
keccak256
public static byte[] keccak256(byte[] data, int offset, int length)
Compute the Keccak256 hash of byte array segment- Parameters:
data
- Input dataoffset
- Start offset in the arraylength
- Length of bytes to compute- Returns:
- byte[]
-
sha3_256
public static byte[] sha3_256(byte[] data, int offset, int length)
Compute the SHA3-256 hash of byte array segment- Parameters:
data
- Input dataoffset
- Start offset in the arraylength
- Length of bytes to compute- Returns:
- byte[]
-
keccak256
public static byte[] keccak256(byte[] data)
Compute the Keccak256 hash of a byte array- Parameters:
data
- Input data- Returns:
- byte[]
-
sha3_256
public static byte[] sha3_256(byte[] data)
Compute the SHA3-256 hash of a byte array- Parameters:
data
- Input data- Returns:
- byte[]
-
keccak256
public static byte[] keccak256(String string)
Compute the Keccak256 hash of string, with UTF-8 encoding- Parameters:
string
- Input string- Returns:
- byte[]
-
sha3_256
public static byte[] sha3_256(String string)
Compute the SHA3-256 hash of string, with UTF-8 encoding- Parameters:
string
- Input string- Returns:
- byte[]
-
keccak256String
public static String keccak256String(String string)
Compute the Keccak256 hash of string, with UTF-8 encoding- Parameters:
string
- Input string- Returns:
- Keccak256 hash as a hex string
-
keccak256String
public static String keccak256String(byte[] data)
Compute the Keccak256 hash of byte array- Parameters:
data
- Input data- Returns:
- Keccak256 hash as a hex string
-
sha3_256String
public static String sha3_256String(byte[] data)
Compute the sha3_256 hash of byte array- Parameters:
data
- Input data- Returns:
- sha3_256 hash as a hex string
-
-