Saturday 15 May 2010

java - MD5 Hashing returning different output than expected -


I'm adding lamp using JDBC and I got word LondonWeight divided into pieces using a MD5 password is required to check the input password against then I store on a MySQL database, ie Lndnwait to see whether they match. Though my Java code in a separate production words hashing

MySQL Hash: 1274d1c52d7a5a9125bd64f1f9a26dce

Java hash: 132310771724320562704545645352563257040366

Here is my hash code: < / p>

  private string hashPass (with string) throws NoSuchAlgorithmException {MessageDigest mdEnc = MessageDigest.getInstance ( "MD5"); MdEnc.update (pass.getBytes (), 0, pass.length ()); String MD5 = new BigIntega (1, MDACDeGest ()). Tosting (8); // Encrypted Returns MD5; }   

It definitely enters the string into the text box because I print it on the terminal so that I can check it. Any idea why it gives a different output? I understand there bytes in a different way to hashes or something?

After

are currently converting to hash. Octal in Java, while MySQL version in hex

This is the first problem, but also:

  • appears your MySQL hash 33 The letter, which has a lot of data for MD5 hash in Hex. There is something strange going on there
  • I do not use BigInteger anyway to change a byte array in Hex. It's not that what's the use of Apache Commons codec for HEX conversion or designed something, for example, in this way, you'll get the appropriate leading zodiac which is BigInteger Press
  • Your current code considers a single byte per character
  • Your current code assumes that the default character encoding is appropriate; I always vulnerable to use String.getBytes I
  • MD5 password hashing; If you can possibly then update to a more appropriate hash

No comments:

Post a Comment