MD5

作者: Il_mondo | 来源:发表于2018-06-06 13:09 被阅读0次
    public class MD5 {
    
        public static String toMD5(String string) throws NoSuchAlgorithmException, 
                UnsupportedEncodingException {
    
            byte[] hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
            StringBuilder hex = new StringBuilder(hash.length * 2);
            for (byte b : hash) {
                if ((b & 0xFF) < 0x10)
                    hex.append("0");
                hex.append(Integer.toHexString(b & 0xFF));
            }
    
            return hex.toString();
        }
    }
    

    相关文章

      网友评论

          本文标题:MD5

          本文链接:https://www.haomeiwen.com/subject/frjbsftx.html