PasswordUtils.java 771 B

1234567891011121314151617181920212223242526272829303132
  1. package com.gz.utils;
  2. import cn.hutool.core.util.IdUtil;
  3. import cn.hutool.crypto.SecureUtil;
  4. /**
  5. * 密码utils
  6. * @author LiuchangLan
  7. * @date 2021/1/27 10:24
  8. */
  9. public class PasswordUtils {
  10. public static String encryption(String password,String salt){
  11. return SecureUtil.md5(password + salt);
  12. }
  13. public static boolean verification(String inputPassword,String salt,String password){
  14. return encryption(inputPassword,salt).equals(password);
  15. }
  16. public static void main(String[] args) {
  17. String password = "123456";
  18. String salt = IdUtil.simpleUUID();
  19. System.out.println("密码:" + encryption(password,salt));
  20. System.out.println("盐" + salt);
  21. System.out.println(IdUtil.simpleUUID());
  22. }
  23. }