Android Utililty Methods MD5 Encode

List of utility methods to do MD5 Encode

Description

The list of methods to do MD5 Encode are organized into topic(s).

Method

StringMD5Crypto(String str)
MD Crypto
try {
    MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.update(str.getBytes());
    byte messageDigest[] = digest.digest();
    return toHexString(messageDigest);
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
return "";
StringgetMD5Str(String str)
get MD Str
MessageDigest messageDigest = null;
try {
    messageDigest = MessageDigest.getInstance("MD5");
    messageDigest.reset();
    messageDigest.update(str.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
    System.out.println("NoSuchAlgorithmException caught!");
    System.exit(-1);
...
Stringmd5(String s)
md
MessageDigest digest;
try {
    digest = MessageDigest.getInstance("MD5");
    digest.update(s.getBytes(), 0, s.length());
    String hash = new BigInteger(1, digest.digest()).toString(16);
    if (hash.length() % 2 != 0) {
        return "0" + hash;
    return hash;
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
return "";
StringMD5(String s)
MD
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
        '9', 'a', 'b', 'c', 'd', 'e', 'f' };
try {
    byte[] strTemp = s.getBytes();
    MessageDigest mdTemp = MessageDigest.getInstance("MD5");
    mdTemp.update(strTemp);
    byte[] md = mdTemp.digest();
    int j = md.length;
...
StringMD5Crypto(String str)
MD Crypto
try {
    MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.update(str.getBytes());
    byte messageDigest[] = digest.digest();
    return toHexString(messageDigest);
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
return "";
StringstringToMD5(String string)
string To MD
byte[] hash;
try {
    hash = MessageDigest.getInstance("MD5").digest(
            string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
    return null;
} catch (UnsupportedEncodingException e) {
...
Stringmd5sum(String string)
mdsum
byte[] hash;
try {
    hash = MessageDigest.getInstance("MD5").digest(
            string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException("Huh, MD5 should be supported?", e);
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException("Huh, UTF-8 should be supported?", e);
...
StringMD5(String str)
MD
return hash(str, "MD5");
StringMD5Encode(String origin)
MD Encode
String resultString = null;
try {
    resultString = new String(origin);
    MessageDigest md = MessageDigest.getInstance("MD5");
    resultString = byteArrayToHexString(md.digest(resultString
            .getBytes()));
} catch (Exception ex) {
return resultString;
StringgetMD5Code(String value)
get MD Code
if (value == null) {
    value = "";
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.reset();
    md.update(value.getBytes());
    byte[] md5Bytes = md.digest();
...