`
ninnd
  • 浏览: 21365 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

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);
}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics