package cn.hanghui.outapi.platform.common.utils;

import cn.hutool.extra.spring.SpringUtil;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @author shisl
 * @package cn.hanghui.outapi.platform.common.utils
 * @class PasswordUtils
 * @date 2024/7/1 下午5:19
 * @description
 */
public class PasswordUtils {

    public static String passwd(String passwordToEncode) {
//        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        BCryptPasswordEncoder passwordEncoder = SpringUtil.getBean(BCryptPasswordEncoder.class);
//        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        String encodedPassword = passwordEncoder.encode(passwordToEncode);
        return encodedPassword;
    }

    public static void main(String[] args) {
        // 校验通过
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        boolean matches = passwordEncoder.matches("Nqj##117521", "$2a$10$TLNM/n.wm62uAG2pC2N3eupyyO3fVetx.Kk1ojGRB9eECBAc5jqeS");
        System.out.println(matches);
    }

}
