Skip to content

Instantly share code, notes, and snippets.

@mcatta
Created May 8, 2013 14:08
Show Gist options
  • Save mcatta/5540674 to your computer and use it in GitHub Desktop.
Save mcatta/5540674 to your computer and use it in GitHub Desktop.
Android/Java convert String to MD5
public static String convertPassMd5(String pass) {
String password = null;
MessageDigest mdEnc;
try {
mdEnc = MessageDigest.getInstance("MD5");
mdEnc.update(pass.getBytes(), 0, pass.length());
pass = new BigInteger(1, mdEnc.digest()).toString(16);
while (pass.length() < 32) {
pass = "0" + pass;
}
password = pass;
} catch (NoSuchAlgorithmException e1) {
e1.printStackTrace();
}
return password;
}
@ducan1204
Copy link

Thank you a lot :)))

@giew
Copy link

giew commented Nov 4, 2020

thanks a lot :)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment