使用md5进行数据加密
程序员文章站
2024-03-20 23:15:16
...
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==