Skip to content

Instantly share code, notes, and snippets.

Created February 22, 2023 18:53
What would you like to do?
Compute Hash
//Get the hash's bytes
byte[] bytes = digest.digest();
//This bytes[] has bytes in decimal format;
//Convert it to hexadecimal format
StringBuilder sb = new StringBuilder();
for(int i=0; i< bytes.length ;i++)
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
//return complete hash
return sb.toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment