MD5 32位小写加密

/**
 * MD5 32位小写加密
 * @param encryptStr
 * @return
 */
public static String encrypt32(String encryptStr) {  
       MessageDigest md5;  
       try {  
           md5 = MessageDigest.getInstance("MD5");  
           byte[] md5Bytes = md5.digest(encryptStr.getBytes());  
           StringBuffer hexValue = new StringBuffer();  
           for (int i = 0; i < md5Bytes.length; i++) {  
               int val = ((int) md5Bytes[i]) & 0xff;  
               if (val < 16)  
                   hexValue.append("0");  
               hexValue.append(Integer.toHexString(val));  
           }  
           encryptStr = hexValue.toString();  
       } catch (Exception e) {  
           throw new RuntimeException(e);  
       }  
       return encryptStr;  
   }  

猜你喜欢

转载自blog.csdn.net/qq_30572851/article/details/80425385