In this example, Get MD5 hash in multiple lines of Java has a related example.
I believe that you should be able to do
MessageDigest m=MessageDigest.getInstance("MD5"); m.update(message.getBytes(), 0, message.length()); BigInteger bi = new BigInteger(1,m.digest());
and if you want to print it in the style of "d41d8cd98f00b204e9800998ecf8427e" , you can do
System.out.println(bi.toString(16));
source share