Skip to content

Instantly share code, notes, and snippets.

@basteez
Created September 11, 2018 16:56
Show Gist options
  • Select an option

  • Save basteez/fcea9f270373b6aeab673f8e7e2ae8ea to your computer and use it in GitHub Desktop.

Select an option

Save basteez/fcea9f270373b6aeab673f8e7e2ae8ea to your computer and use it in GitHub Desktop.
JAVA - Create MD5 Hash
public static String getMd5Hash(String baseString) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(baseString.getBytes());
byte byteData[] = md.digest();
StringBuffer sb = new StringBuffer();
for(int i = 0; i < byteData.length; i++) {
sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
}
return sb.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment