| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | return passwordEncoder.matches(rawPassword, encodedPassword); |
| | | } |
| | | |
| | | /** |
| | | * MD5加密 |
| | | * |
| | | * @param str 需要加密的字符串 |
| | | * @return 加密后的字符串 |
| | | */ |
| | | public static String md5(String str) { |
| | | try { |
| | | MessageDigest md = MessageDigest.getInstance("MD5"); |
| | | byte[] bytes = md.digest(str.getBytes()); |
| | | StringBuilder result = new StringBuilder(); |
| | | for (byte b : bytes) { |
| | | String temp = Integer.toHexString(b & 0xff); |
| | | if (temp.length() == 1) { |
| | | temp = "0" + temp; |
| | | } |
| | | result.append(temp); |
| | | } |
| | | return result.toString(); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | throw new RuntimeException("MD5加密失败", e); |
| | | } |
| | | } |
| | | /** |
| | | * 是否为管理员 |
| | | * |