spring-security 解决

引入依赖

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
        </dependency>

测试

    @Test
    public void password() {
        String pass = "admin123";
        BCryptPasswordEncoder bcryptPasswordEncoder = new BCryptPasswordEncoder();
        String hashPass = bcryptPasswordEncoder.encode(pass);
        System.out.println(hashPass);
        hashPass = "$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2";
        boolean flag = bcryptPasswordEncoder.matches("admin123", hashPass);
        System.out.println(flag);
    }

 

posted @ 2021-09-17 17:37  wujf  阅读(591)  评论(0编辑  收藏  举报