先上图,先上图
打印出来的就是md5字段
package com.skyinfor.szls.Util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class md5Encrypt {
public String toMd5(String content){
byte[]hash;
try {
hash = MessageDigest.getInstance("MD5").digest(content.getBytes());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("NoSuchAlgorithmException",e);
}
StringBuilder hex = new StringBuilder(hash.length*2);
for(byte b:hash){
if((b & 0xFF)< 0x10){
hex.append(0);
}
hex.append(Integer.toHexString(b & 0xff));
}
return hex.toString();
}
}
调用:
private md5Encrypt md5;
md5 = new md5Encrypt();
Log.d("----md5---",md5.toMd5(et_password.getText().toString()));