This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.utils;
// 引入Hutool工具包中的DigestUtil类,该类提供了各种摘要算法工具,用于实现MD5加密
import cn.hutool.crypto.digest.DigestUtil;
/**
* MD5Util类用于实现MD5加密功能,借助Hutool工具包中的DigestUtil类完成。
*/
public class MD5Util {
* 此方法用于对传入的明文进行MD5加密。
*
* @param text 待加密的明文,是一个字符串类型的数据。
* @return 返回经过MD5加密后的十六进制字符串形式的密文。
// 带秘钥加密,不过此方法当前未使用密钥,仅对文本进行MD5加密
public static String md5(String text) {
// 利用DigestUtil类的md5Hex方法对传入的明文进行MD5加密,并将加密结果以十六进制字符串形式存储
// 加密后的字符串
String md5str = DigestUtil.md5Hex(text);
// 返回加密后的十六进制字符串
return md5str;
}