package com.bw.qanda.utils; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; /** * @author jian.mao * @date 2023年3月10日 * @description */ public class EncryptionUtil { public static String md5(String text) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(text.getBytes()); byte[] bytes = md.digest(); StringBuilder sb = new StringBuilder(); for (byte b : bytes) { sb.append(String.format("%02x", b & 0xff)); } return sb.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } } }