Here is the code I'm talking about:
md.reset();
What does the reset() method do to the MessageDigest object? Why is it necessary?
Here is the code I'm talking about:
md.reset();
What does the reset() method do to the MessageDigest object? Why is it necessary?
It returns the MessageDigest instance back to its initial state, so that you can use it again for calculating another message digest (as opposed to getting a new instance, which could be expensive or inconvenient).
If you did not call this method, but continued to just shove the second message in, the resulting digest might not be correct (as it could contain "junk" left over from the previous calculation).