Package javatro.storage.utils
Class HashUtil
java.lang.Object
javatro.storage.utils.HashUtil
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgenerateHash(List<String> runData) Generates a SHA-256 hash from a list of strings representing run data.
-
Constructor Details
-
HashUtil
public HashUtil()
-
-
Method Details
-
generateHash
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
nullor 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- AListofStringrepresenting the data to be hashed.- Returns:
- A
Stringcontaining the hexadecimal representation of the SHA-256 hash. - Throws:
RuntimeException- if the hashing algorithm is not available on the platform.
- The input list must not be
-