January 21, 2011

How to create MD5 Hash in Java

I always had a hard time creating a MD5 Hash in java, it should be simple but there is so many ways to do and it never matched with i expect it... The following is what i think is the best way to create a MD5 hash that matches what other languages create.


  1. This comment has been removed by the author.

  2. You can use GrandCentral which creates a password digest based on the time of day using SHA-512. GrandCentral also includes the SimpleCrypto class which can generate hashes and checksums using MD5, SHA1, SHA-256, SHA-384 and SHA-512. Just a suggestion.

  3. be careful to specify the encodinig you get the bytes from the String if not you will be plateform dependant and you will be spending hours wondering why am I getting these results here and different ones there