Class HashUtil

java.lang.Object
javatro.storage.utils.HashUtil

public class HashUtil extends Object
The HashUtil class provides utility methods for generating SHA-256 hashes of game run data. It ensures consistent hashing by normalizing input data before processing.

This utility class is designed to work with the storage mechanism to validate game data integrity.

  • Constructor Details

    • HashUtil

      public HashUtil()
  • Method Details

    • generateHash

      public static String generateHash(List<String> runData)
      Generates a SHA-256 hash from a list of strings representing run data. This method ensures consistency by trimming whitespace, replacing empty or placeholder values with "NA", and concatenating entries with commas before hashing.

      Assertions:

      • The input list must not be null or empty.
      • Each data entry must not be null.
      • Data entries should not contain commas to prevent corruption of the CSV structure.
      • The final concatenated data string must not be empty before hashing.
      • The generated hash must not be empty and should have a length of 64 characters (for SHA-256).
      Parameters:
      runData - A List of String representing the data to be hashed.
      Returns:
      A String containing the hexadecimal representation of the SHA-256 hash.
      Throws:
      RuntimeException - if the hashing algorithm is not available on the platform.