Skip to content

Instantly share code, notes, and snippets.

@greenlikeorange
Created July 17, 2015 16:56
Show Gist options
  • Save greenlikeorange/7f7e749af54fd170ff0f to your computer and use it in GitHub Desktop.
Save greenlikeorange/7f7e749af54fd170ff0f to your computer and use it in GitHub Desktop.
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