I am trying an example:
String hashAlgorithm ="sha-256"
...
md=MessageDigest.getInstance(hashAlgorithm);
byte[] enteredPasswordDigest = md.digest(policy.getPassword().getBytes());
if (!MessageDigest.isEqual(enteredPasswordDigest, realPassword.getBytes())) {
...
}
However, the hashed password is stored as a string in the database. When I do that comparison, it fails. When I debug it, enteredPasswordDigest has 32 byte length and realPassword.getBytes() has 64 byte length.
What did I miss?