// 将指定字符串经过MD5加密后返回
<span style="font-family:Arial;background-color: rgb(255, 255, 255);">public static String encode(String pwd){
if(null == pwd){
return null;
}
String[] str = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
StringBuilder sb = new StringBuilder();
MessageDigest digest;
try {
digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
byte[] b = digest.digest(pwd.getBytes());
for(byte single : b){
sb.append(str[(single >> 4) & 0x0f]); // 高四位
sb.append(str[single&0x0f]); // 低四位
}
return sb.toString();
}</span>