Here you can find the source of digest(String source, byte[] salt)
public static String digest(String source, byte[] salt)
//package com.java2s; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /**//from w w w .j a v a 2s . com * Default encoding */ private static final String DEFAULT_ENCODING = "utf-8"; /** * Used to build output as Hex */ private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; public static String digest(String source, byte[] salt) { try { return new String(encode(digest(source.getBytes(DEFAULT_ENCODING), salt))); } catch (UnsupportedEncodingException ex) { throw new RuntimeException("PasswordCrypter's error has occured!", ex); } catch (RuntimeException ex) { throw ex; } } private static byte[] digest(byte[] source, byte[] salt) { try { MessageDigest md5Digest = MessageDigest.getInstance("md5"); md5Digest.reset(); md5Digest.update(salt); return md5Digest.digest(source); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("PasswordCrypter's error has occured!", ex); } } public static String encode(byte[] data) { int len = data.length; char[] out = new char[len << 1]; // two characters form the hex value. for (int i = 0, j = 0; i < len; i++) { out[j++] = DIGITS[(0xF0 & data[i]) >>> 4]; out[j++] = DIGITS[0x0F & data[i]]; } return new String(out); } }