Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) {2009,2011} {Software Design and Collaboration Laboratory (SDCL) * , University of California, Irvine}. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * {Software Design and Collaboration Laboratory (SDCL) * , University of California, Irvine} * - initial API and implementation and/or initial documentation *******************************************************************************/ import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String getMD5Hash(String s) throws NoSuchAlgorithmException { MessageDigest m = MessageDigest.getInstance("MD5"); byte[] data = s.getBytes(); m.update(data, 0, data.length); BigInteger i = new BigInteger(1, m.digest()); return String.format("%1$032X", i); } }