使用 BCryptPasswordEncoder 随机盐加密步骤:
1.导入springboot的安全框架依赖:
<!-- BCryptPasswordEncoder 加密-->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.0.1.RELEASE</version>
</dependency>
2.初始化 BCryptPasswordEncoder
package cn.mindgd.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
* 加密工具初始化
*/
@Configuration
public class PasswordConfig {