Android MD5 Encode md5(String input)

Here you can find the source of md5(String input)

Description

md

Declaration

public static String md5(String input) 

Method Source Code

//package com.java2s;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static String md5(String input) {
        String res = "";
        try {//w w w.  j  a v a 2s.  c  om
            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++) {
                tmp = (Integer.toHexString(0xFF & md5[i]));
                if (tmp.length() == 1) {
                    res += "0" + tmp;
                } else {
                    res += tmp;
                }
            }
        } catch (NoSuchAlgorithmException ex) {
        }
        return res;
    }
}

Related

  1. getMD5(byte[] source)
  2. md5(String string)
  3. createHMACWithMD5(String source, String key)
  4. md5(String text)
  5. encryptByUsingMd5(String passwd)
  6. isValidMD5String(String md5String)
  7. stringToMD5(String key)
  8. toMD5(final String toEncrypt)