使用md5进行数据加密

public void test() throws NoSuchAlgorithmException, UnsupportedEncodingException {
        String str = "hello";
        String str1 = "hello";

        MessageDigest md5 = MessageDigest.getInstance("MD5");
        Base64.Encoder base64Encoder = Base64.getEncoder();

        str = base64Encoder.encodeToString(md5.digest(str.getBytes("utf-8")));
        str1 = base64Encoder.encodeToString(md5.digest(str1.getBytes("utf-8")));

        System.out.println("加密后字符传str:"+str);
        System.out.println("加密后字符传str1:"+str1);

    }
加密后字符传str:XUFAKrxLKna5cZ2REBfFkg==
加密后字符传str1:XUFAKrxLKna5cZ2REBfFkg==

你可能感兴趣的:(重要技术)