Reconciling Java and PHP MD5 Hashes

I wasn't sure where the right place for this is but since the PHP hash function has little room for silly errors, I decided that the real issue must be in my Java method. I have a hash generated with PHP that gets passed to a Java app. The Java app then tries to reproduce that hash using the same input string so they can be compared for validation purposes. Unfortunately the resultant hashes are different. Here is the relevant code segment:

Thanks for the reply. I guess I am not sure what you mean. Both strings are numeric characters only (with a single intervening space) and the resulting strings look the same. I will double check the lengths to make sure there are no unprintable characters but I doubt that is it.

There are 10 kinds of people in the world. Those that understand binary and those that don't.

By the way, that BigInteger is problematic, because the byte array is interpreted as a two's complement. If the MD5 hash starts with a 1, you'll get a "random" negative number instead of the actual hexadecimal representation.

You could fix that by simply prepending a 0 to the by array. But I'm pretty sure there are better ways to get the hex representation of a byte array.