I have two md5 hash password that are the same and should return true using the MessageDigest.isEqual method. However the comparison returns false.
When using Array.toString to print the byte-Arrays, they are identical. It still doesn't work, neither for Arrays.euqals nor for MessageDigest.isEqual.
public boolean verifyUserCredentials(String username, MessageDigest password) {
ListIterator<User> iterator = userList.listIterator();
while (iterator.hasNext()) {
User user = iterator.next();
byte md1[] = user.getPassword().digest();
byte md2[] = password.digest();
if (user.getUsername() == username && MessageDigest.isEqual(md1, md2)) {
return true;
}
}
return false;
}