Skip to content

Instantly share code, notes, and snippets.

@hkneptune
Created October 9, 2023 03:58
Show Gist options
  • Save hkneptune/578ba6f21fc11b28c9f697ad77a23803 to your computer and use it in GitHub Desktop.
Save hkneptune/578ba6f21fc11b28c9f697ad77a23803 to your computer and use it in GitHub Desktop.
SHA256Sum
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