Created
September 11, 2018 16:56
-
-
Save basteez/fcea9f270373b6aeab673f8e7e2ae8ea to your computer and use it in GitHub Desktop.
JAVA - Create MD5 Hash
This file contains hidden or 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 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