首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring security2.0盐值加密步骤

2012-08-22 
spring security2.0盐值加密方法public static String ge**5(String salt, String str)throws NoSuchAlgor

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);}
?

热点排行