图片防止篡改部分
//将图片使用md5加密
private static byte[] img2Md5Bytes(File file,String salt) throws Exception{
FileInputStream inputStream=new FileInputStream(file);
StringBuilder builder=new StringBuilder();
byte[] bytes=new byte[1024];
int bytesRead;
while ((bytesRead=inputStream.read(bytes))!=-1){
builder.append(new String(bytes,0,bytesRead));
}
inputStream.close();
builder.append(salt);
String md5=md5(builder.toString());
return hexStringToBytes(md5);
}
//16进制转字节数组
private static byte[] hexStringToBytes(String hexString) {
if (hexString == null || hexString.equals("")) {
return null;
}
hexString = hexString.toUpperCase();
int length = hexString.length() / 2;
char[] hexChars = hexS