public class MD5Encrypts{
public static String Md5Encryption(String str){
String byteStr = null;
return byteStr;
}
public static String getMD5HashFromFile(String filePath){
try{
FileInputStream fis=new FileInputStream(filePath);
//获取MD5转换器
MessageDigest md=MessageDigest.getInstance("MD5");
byte[] bytes=new byte[1024*1024*10];
int length=-1;
while((length=fis.read(bytes, 0, 1024*1024))!=-1){
md.update(bytes, 0, length);
}
fis.close();
//转换并返回包含16元素字节数组
byte[] md5Bytes=md.digest();
BigInteger bigInt=new BigInteger(1, md5Bytes); //1代表绝对值
//转换为16进制
return bigInt.toString(16);
}catch(Exception e){
e.printStackTrace();
return "";
}
}
}