This test seems to be in favour of caching
long t0 = System.currentTimeMillis();
byte[] bytes = new byte[100];
MessageDigest md = MessageDigest.getInstance("MD5");
for(int i = 0; i < 1000000; i++) {
//MessageDigest md = MessageDigest.getInstance("MD5");
md.reset();
md.update(bytes);
md.digest();
}
System.out.println(System.currentTimeMillis() - t0);
When md is outside the loop it prints 579, when inside - 953.