try {
byte[] bytesOfMessage = YOURSTRING.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] bytesOfDigest = md.digest(bytesOfMessage);
String hash = DatatypeConverter.printHexBinary(bytesOfDigest).toLowerCase();
System.out.println(hash);
} catch(Exception e) {
System.out.println(e);
}