Here you can find the source of md5(String string)
public static byte[] md5(String string)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /** Hashes the given {@code string} using the MD5 algorithm. */ public static byte[] md5(String string) { return hash("MD5", string); }/*from w w w . j a v a2s.c o m*/ /** Hashes the given {@code string} using the given {@code algorithm}. */ public static byte[] hash(String algorithm, String string) { MessageDigest digest; try { digest = MessageDigest.getInstance(algorithm); } catch (NoSuchAlgorithmException ex) { throw new IllegalArgumentException(String.format("[%s] isn't a valid hash algorithm!", algorithm), ex); } byte[] bytes; try { bytes = string.getBytes("UTF-8"); } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } return digest.digest(bytes); } }