I have a java code where I am sending an md5 has over the socket to receive on the other side. I take in a password as the input and create its own md5 to check with the md5 recieved over the socket to authenticate.
Both the md5 strings have the same byte pattern, but the String.equals() returns a false when I do an equality test on both the md5 patterns. How can this be possible ?. Please help if anyone has an idea of what might be wrong ?
MD5 is a
byte[]. It’s representation is usually a hex-string. The things to look at:new String(bytes). This uses the default encoding, which varies across machines, and the encoding might not support some byte values.But you shouldn’t compare the representation. You should compare the bytes:
Arrays.equals(ar1, ar2)