Here you can find the source of md5(String raw)
public static String md5(String raw)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String raw) { return digest(raw, "MD5"); }//from w w w.j av a2 s . c o m private static String digest(String raw, String algorithm) { if (raw == null || "".equals(raw)) return ""; MessageDigest md; try { md = MessageDigest.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } md.update(raw.getBytes()); StringBuilder sb = new StringBuilder(); for (byte b : md.digest()) { String hex = String.format("%02x", b); sb.append(hex); } return sb.toString(); } }