Skip to content

Instantly share code, notes, and snippets.

@Igvir
Created February 22, 2023 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Igvir/d8af1d8a59c2e678790fa5f7067c9691 to your computer and use it in GitHub Desktop.
Save Igvir/d8af1d8a59c2e678790fa5f7067c9691 to your computer and use it in GitHub Desktop.
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