Here you can find the source of generateHash(String input, String salt)
public static String generateHash(String input, String salt) throws NoSuchAlgorithmException, UnsupportedEncodingException
//package com.java2s; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String generateHash(String input, String salt) throws NoSuchAlgorithmException, UnsupportedEncodingException { // SHA or MD5 MessageDigest md = MessageDigest.getInstance("MD5"); String hash = ""; if (salt == null) { salt = ""; }/* w w w.ja va 2 s . co m*/ input += salt; byte[] data = input.getBytes("US-ASCII"); md.update(data); byte[] digest = md.digest(); for (int i = 0; i < digest.length; i++) { String hex = Integer.toHexString(digest[i]); if (hex.length() == 1) hex = "0" + hex; hex = hex.substring(hex.length() - 2); hash += hex; } return hash; } }