Created
October 9, 2023 03:58
-
-
Save hkneptune/578ba6f21fc11b28c9f697ad77a23803 to your computer and use it in GitHub Desktop.
SHA256Sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String sha256(File input) throws IOException { | |
Digest sha256 = new Digest(); | |
sha256.update(Files.readAllBytes(input.toPath())); | |
StringBuilder buff = new StringBuilder(); | |
for (byte b : sha256.digest()) { | |
buff.append(String.format("%02x", b & 0xFF)); | |
} | |
return buff.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment