Here you can find the source of generateHash(String target)
public static String generateHash(String target)
//package com.java2s; /*// w w w . j a va2 s.c om * Protorabbit * * Copyright (c) 2009 Greg Murray (protorabbit.org) * * Licensed under the MIT License: * * http://www.opensource.org/licenses/mit-license.php * */ import java.security.MessageDigest; public class Main { public static String generateHash(String target) { if (target != null) { String hash = null; try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] bytes = md.digest(target.getBytes()); // buffer to write the md5 hash to StringBuffer buff = new StringBuffer(); for (int l = 0; l < bytes.length; l++) { String hx = Integer.toHexString(0xFF & bytes[l]); // make sure the hex string is correct if 1 character if (hx.length() == 1) { buff.append("0"); } buff.append(hx); } hash = buff.toString().trim(); } catch (java.security.NoSuchAlgorithmException e) { } return hash; } return null; } }