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

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) {
    return null;
} catch (UnsupportedEncodingException e) {
...
StringMD5(String text)
private stuff for converting strings to md5.
MessageDigest md;
md = MessageDigest.getInstance("MD5");
byte[] md5hash = new byte[32];
md.update(text.getBytes("UTF-8"), 0, text.length());
md5hash = md.digest();
return convertToHex(md5hash);
StringstringGetMD5String(String s)
string Get MD String
byte[] data;
MessageDigest md5;
try {
    data = s.getBytes("UTF-8");
    md5 = MessageDigest.getInstance("MD5");
} catch (Exception e) {
    return null;
byte[] hash = md5.digest(data);
StringBuilder hashStr = new StringBuilder();
for (byte byteValue : hash) {
    hashStr.append(String.format("%02x", byteValue));
return hashStr.toString();
StringbyteMd5(String plainText, Boolean is16)
byte Md
StringBuffer buf = new StringBuffer();
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(plainText.getBytes());
    byte b[] = md.digest();
    int i;
    for (int offset = 0; offset < b.length; offset++) {
        i = b[offset];
...
StringgetMD5(byte[] source)
get MD
try {
    MessageDigest md5 = MessageDigest.getInstance("MD5");
    StringBuffer result = new StringBuffer();
    for (byte b : md5.digest(source)) {
        result.append(Integer.toHexString((b & 0xf0) >>> 4));
        result.append(Integer.toHexString(b & 0x0f));
    return result.toString();
...
Stringmd5(String string)
md
if (string == null || string.trim().length() < 1) {
    return null;
try {
    return getMD5(string.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e.getMessage(), e);
StringcreateHMACWithMD5(String source, String key)
create HMAC With MD
Mac hmac = Mac.getInstance("HmacMD5");
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(),
        hmac.getAlgorithm());
hmac.init(secretKey);
byte[] signature = hmac.doFinal(source.getBytes());
return Base64.encodeToString(signature, Base64.DEFAULT);
Stringmd5(String text)
md
if (text == null) {
    return null;
} else {
    try {
        byte[] bytesOfMessage = text.getBytes();
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        byte[] hash = md5.digest(bytesOfMessage);
        StringBuilder hexDigest = new StringBuilder();
...
StringencryptByUsingMd5(String passwd)
encrypt By Using Md
try {
    MessageDigest sha = MessageDigest.getInstance("MD5");
    byte[] tmp = passwd.getBytes();
    sha.update(tmp);
    return new String(sha.digest());
} catch (java.security.NoSuchAlgorithmException e) {
    System.out.println("Rats, MD5 doesn't exist");
    System.out.println(e.toString());
...
Stringmd5(String input)
md
String res = "";
try {
    MessageDigest algorithm = MessageDigest.getInstance("MD5");
    algorithm.reset();
    algorithm.update(input.getBytes());
    byte[] md5 = algorithm.digest();
    String tmp = "";
    for (int i = 0; i < md5.length; i++) {
...