1、md5新建类:
public class MD5 {public static String toMD5(String str) { str="zgqrxlb"+str; byte[] source = new byte[0]; try { source = str.getBytes("ascii"); } catch (UnsupportedEncodingException e) { e.PRintStackTrace(); } MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } md.update(source); StringBuffer buf = new StringBuffer(); for (byte b : md.digest()) buf.append(String.format("%02x", b & 0xff));//%02x return buf.toString().toUpperCase(Locale.getDefault()).substring(0,26);}}2、在需要加密(这里是给密码加密)的地方调用上面的工具类
String ss= MD5.toMD5(et_register_passWord.getText().toString()); mPassWord=MD5.toMD5(ss+"a!b@c#"); Log.d("mPassWord",mPassWord);
新闻热点
疑难解答