es应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
620 B

7 months ago
  1. package com.bfd.operate.utils;
  2. import java.security.MessageDigest;
  3. import java.security.NoSuchAlgorithmException;
  4. /**
  5. * @author jian.mao
  6. * @date 2023年3月10日
  7. * @description
  8. */
  9. public class EncryptionUtil {
  10. public static String md5(String text) {
  11. try {
  12. MessageDigest md = MessageDigest.getInstance("MD5");
  13. md.update(text.getBytes());
  14. byte[] bytes = md.digest();
  15. StringBuilder sb = new StringBuilder();
  16. for (byte b : bytes) {
  17. sb.append(String.format("%02x", b & 0xff));
  18. }
  19. return sb.toString();
  20. } catch (NoSuchAlgorithmException e) {
  21. e.printStackTrace();
  22. return null;
  23. }
  24. }
  25. }