Package sg.dex.crypto

Class Hash


  • public class Hash
    extends Object
    Utility class for hash functions
    Author:
    Mike
    • Field Detail

      • EMPTY_BYTES_SHA3

        public static final byte[] EMPTY_BYTES_SHA3
    • Constructor Detail

      • Hash

        public Hash()
    • Method Detail

      • keccak256

        public static byte[] keccak256​(byte[] data,
                                       int offset,
                                       int length)
        Compute the Keccak256 hash of byte array segment
        Parameters:
        data - Input data
        offset - Start offset in the array
        length - 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 data
        offset - Start offset in the array
        length - 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
      • sha3_256String

        public static String sha3_256String​(String string)
        Compute the sha3_256 hash of string, with UTF-8 encoding
        Parameters:
        string - Input string
        Returns:
        sha3_256 hash as a hex string