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;
}
@Gabrock94
Copy link

Thank you!

@walageri
Copy link

i see. this work.. but how to descrytion to value string

@Ashok-Varma
Copy link

@walageri Hashs can only be performed in one direction.

You can't decrypt => Instead you can convert string (password) to Hash again and compare with previous generated value

@raiszainuri
Copy link

thanks :)

Copy link

ghost commented May 22, 2019

thank you =)

@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