Java 生成字符串的 MD5 值

    public static String generateMD5(String... infos) {
    
    
        try {
    
    
            MessageDigest sMd5Digest = MessageDigest.getInstance("MD5");
            String allInfo = String.join("-", infos);
            byte[] hash = sMd5Digest.digest(allInfo.getBytes());
            BigInteger numValue = new BigInteger(1, hash);
            return numValue.toString(16);
        } catch (NoSuchAlgorithmException e) {
    
    
            e.printStackTrace();
        }
        return "00000000000000000000000000000000";
    }

猜你喜欢

转载自blog.csdn.net/hegan2010/article/details/106129273