Class Utils

    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • hashing

        public static MessageDigest hashing​(MessageDigest md,
                                            InputStream in)
        Run the hash with the pass in MessageDigest and InputStream
        Parameters:
        md - The MessageDigest to be used.
        in - The InputStream of the data to be hashed.
        Returns:
        The MessageDigest object after doing the hashing.
      • getHash

        public static byte[] getHash​(String algorithm,
                                     InputStream in)
        Calculate and return the hash value with byte array.
        Parameters:
        algorithm - The string to indicate the hashing algorithm to be used.
        in - The InputStream of the data to be hashed.
        Returns:
        The hash value in byte array.
      • translateHashToString

        public static String translateHashToString​(byte[] hash)
        Translate the byte array into Hex String.
        Parameters:
        hash - The byte array of hash value.
        Returns:
        The string of the hash value in Hex.
      • isMatch

        public static boolean isMatch​(String actualString,
                                      LinkedList patterns,
                                      char wildCard)
        Check whether the string matches the pattern.
        Parameters:
        actualString - The string to be checked.
        patterns - A list of patterns to check for.
        wildCard - A character which is used as wild card in the pattern.
        Returns:
        Whether the string matches one of the patterns in the list.
      • isMatch

        public static boolean isMatch​(String actualString,
                                      String pattern,
                                      char wildCard)
        Check whether the string matches the pattern.
        Parameters:
        actualString - The string to be checked.
        pattern - A pattern to check for.
        wildCard - A character which is used as wild card in the pattern.
        Returns:
        Whether the string matches one of the patterns in the list.