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

booleanisValidMD5String(String md5String)
is Valid MD String
if (md5String != null) {
    return md5String.length() == 32;
return false;
StringstringToMD5(String key)
string To MD
String cacheKey;
try {
    final MessageDigest mDigest = MessageDigest.getInstance("MD5");
    mDigest.update(key.getBytes());
    cacheKey = bytesToHexString(mDigest.digest());
} catch (NoSuchAlgorithmException e) {
    cacheKey = String.valueOf(key.hashCode());
return cacheKey;
StringtoMD5(final String toEncrypt)
to MD
try {
    final MessageDigest digest = MessageDigest.getInstance("md5");
    digest.update(toEncrypt.getBytes());
    final byte[] bytes = digest.digest();
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < bytes.length; i++) {
        sb.append(String.format("%02X", bytes[i]));
    return sb.toString().toLowerCase();
} catch (Exception exc) {
    return null;