Java calculate MD5 hash
use org.apache.commons.codec.digest.DigestUtils
instead:
DigestUtils.md5Hex(str);
this will give you 32 char string as a result
You must be missing something. The linked code is just fine. Make sure the issue is nowhere else, related to displaying the result. Possibilities:
- in a GUI too small
- in a console with multithreading issues
- over a network package which is being cut off to soon
- you cut the length to
20
instead of0x20
, which is32
.