public class StringUtils {public static string Md5encode (String origin) {String resultstring = null;try { resultstring = new String (origin); MessageDigest MD = messagedigest.getinstance ("MD5"); resultstring = bytearraytohexstring (Md.digest (Resultstring.getbytes ()));} catch (Exception ex) { }return resultstring;} public static String bytearraytohexstring (byte[] b) {StringBuffer RESULTSB = new StringBuffer (), for (int i = 0; i < B.L Ength; i++) {resultsb.append (bytetohexstring (B[i]));} return resultsb.tostring ();} private static String bytetohexstring (byte b) {int n = b;if (n < 0) n = n;int + D1 = N/16;int D2 = n 16;return H EXDIGITS[D1] + hexdigits[d2];} Private final static string[] hexdigits = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "B", "C", "D", "E", "F"}; }
How Android Converts a string to MD5 + some commonly used methods of string