Skip to content

Commit

Permalink
[New] Added FileHelper.hashFileSha256AsHex()
Browse files Browse the repository at this point in the history
  • Loading branch information
eitch committed Jul 15, 2024
1 parent 0e7ecf1 commit 5a6af26
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions utils/src/main/java/li/strolch/utils/helper/FileHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,17 @@ public static byte[] hashFileSha256(File file) {
return FileHelper.hashFile(file, "SHA-256");
}

/**
* Creates the SHA256 hash of the given file, returning the hash as a HEX string.
*
* @param file the file to hash
*
* @return the hash as a HEX string
*/
public static String hashFileSha256AsHex(File file) {
return StringHelper.toHexString(FileHelper.hashFile(file, "SHA-256"));
}

/**
* Creates the hash of the given file with the given algorithm, returning the hash as a byte array. Use
* {@link StringHelper#toHexString(byte[])} to create a HEX string of the bytes
Expand Down

0 comments on commit 5a6af26

Please sign in to comment.