1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
public static String (String source){ try { MessageDigest md5 = MessageDigest.getInstance("MD5"); return bytesConvertToHexString(md5.digest(source.getBytes())); }catch (Exception e){ } return null; }
public static String bytesConvertToHexString(byte [] bytes) { StringBuffer sb = new StringBuffer(); for (byte aByte : bytes) { String s= Integer.toHexString(0xff & aByte); if(s.length()==1){ sb.append("0"+s); }else{ sb.append(s); } } return sb.toString(); }
|
近期评论