From 5a6af26ae0e6886ba828613bbe1bec77d1babc2a Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Mon, 15 Jul 2024 21:12:43 +0200 Subject: [PATCH] [New] Added FileHelper.hashFileSha256AsHex() --- .../main/java/li/strolch/utils/helper/FileHelper.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utils/src/main/java/li/strolch/utils/helper/FileHelper.java b/utils/src/main/java/li/strolch/utils/helper/FileHelper.java index 09f59e40f..60ec828d3 100644 --- a/utils/src/main/java/li/strolch/utils/helper/FileHelper.java +++ b/utils/src/main/java/li/strolch/utils/helper/FileHelper.java @@ -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