Class FileHashHandler

java.lang.Object
lib.pwss.hash.file_hash_handler.FileHashHandler
All Implemented Interfaces:
FileHash

public final class FileHashHandler extends Object implements FileHash
The FileHashHandler class provides methods for calculating hash values of a file using various hashing algorithms. This includes SHA-256, SHA-3 (256), and BLAKE2b. It returns the calculated hash values in a structured format.
  • Field Details

  • Constructor Details

    • FileHashHandler

      public FileHashHandler()
      Public Constructor
  • Method Details

    • calculateSha256Hash

      public final String calculateSha256Hash(File file)
      Calculates the SHA256 Hash of a file
      Specified by:
      calculateSha256Hash in interface FileHash
      Parameters:
      file - to extract hash from
      Returns:
      A string containing the hexadecimal representation of the bytes in SHA2 Hash
    • calculateSha3Hash

      public final String calculateSha3Hash(File file)
      Calculates the SHA3 Hash of a file
      Specified by:
      calculateSha3Hash in interface FileHash
      Parameters:
      file - to extract hash from
      Returns:
      A string containing the hexadecimal representation of the bytes in SHA3 Hash
    • calculateBlake2bHash

      public final String calculateBlake2bHash(File file)
      Calculates the Blake2B Hash of a file
      Specified by:
      calculateBlake2bHash in interface FileHash
      Parameters:
      file - to extract hash from
      Returns:
      A string containing the hexadecimal representation of the bytes in a Blake2B Hash
    • bytesToHex

      protected final String bytesToHex(byte[] bytes)
      Convert a byte sequence to its hexadecimal string representation. This function takes a bytes object and returns a string containing two hexadecimal digits for each byte in the input, using lowercase letters.
      Parameters:
      bytes - (bytes): The byte sequence to be converted to hexadecimal.
      Returns:
      str: A string containing the hexadecimal representation of the bytes.
    • GetAllHashes

      public final HashForFilesOutput GetAllHashes(File file)
      Calculates hashes of three different algorithms (SHA2,SHA3, BLAKE_2B) of a file
      Parameters:
      file - The file to extract hash from
      Returns:
      A wrapper object containing the file and the three resulting hash strings