Here you can find the source of md5(String string)
public static String md5(String string)
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String string) { return md5(StandardCharsets.UTF_8.encode(string)); }// w w w . j a va2s . c o m public static String md5(byte[] data) { return md5(ByteBuffer.wrap(data)); } public static String md5(ByteBuffer data) { try { MessageDigest hash = MessageDigest.getInstance("MD5"); hash.update(data); return String.format("%032x", new BigInteger(1, hash.digest())); // as hex string } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } }