Can someone tell me what is wrong with this code? Each time I use it on the same file, it gives a different hash code
public static byte[] generateHash(String file)
{
InputStream is;
try
{
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
is = new FileInputStream(file);
is = new DigestInputStream(is, algorithm);
is.close();
return algorithm.digest();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}