spring security2.0塩値暗号化方法


public static String ge**5(String salt, String str)
            throws NoSuchAlgorithmException {
        str = str + "{" + salt + "}";//         
        byte[] strBytes = str.getBytes();
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] digest = md.digest(strBytes);
        char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
                'a', 'b', 'c', 'd', 'e', 'f' };
        int j = digest.length;
        char strs[] = new char[j * 2];
        int k = 0;
        for (int i = 0; i < j; i++) {
            byte b = digest[i];
            strs[k++] = hexDigits[b >> 4 & 0xf];
            strs[k++] = hexDigits[b & 0xf];
        }
        return new String(strs);
}