Created
July 17, 2015 16:56
-
-
Save greenlikeorange/7f7e749af54fd170ff0f to your computer and use it in GitHub Desktop.
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
| import java.security.MessageDigest; | |
| class Hasher { | |
| public static string getMD5(String password){ | |
| MessageDigest md = MessageDigest.getInstance("MD5"); | |
| md.update(password.getBytes()); | |
| byte byteData[] = md.digest(); | |
| //convert the byte to hex format method 1 | |
| 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