package edu.whut.smilepicturebackend.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

//BCrypt加密工具类，不如Bean注入效率更高，已废弃。
public class PasswordUtils {

    private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();

    /**
     * 加密密码
     */
    public static String encode(String rawPassword) {
        return encoder.encode(rawPassword);
    }

    /**
     * 校验密码是否匹配
     */
    public static boolean matches(String rawPassword, String encodedPassword) {
        return encoder.matches(rawPassword, encodedPassword);
    }
}
