1.首先新建两个内容相同的文件
2.创建测试类
public class TestMD5 {
public static void main(String[] args) {
try {
FileInputStream file1 = new FileInputStream(new File("C:\\Users\\hp\\Desktop\\md51.txt"));
FileInputStream file2 = new FileInputStream(new File("C:\\Users\\hp\\Desktop\\md52.txt"));
System.out.println(DigestUtil.md5Hex(file1));
System.out.println(DigestUtil.md5Hex(file2));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
打印结果:
202cb962ac59075b964b07152d234b70
202cb962ac59075b964b07152d234b70
3.修改md52.txt的内容
4.打印结果
202cb962ac59075b964b07152d234b70
81dc9bdb52d04dc20036dbd8313ed055
5.引用的jar包
huttool-all-3.3.2.jar