PasswordEncorder.java
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder; /** * @author : Buddhika Lakshan * @Project : Audici_Umgt_Server * @Package : us.audici.umgt.Config * @since : 2020-05-21, Thu **/@Configurationpublic class PasswordEncorder {
@Bean public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
Usage:
@Autowiredprivate PasswordEncoder passwordEncoder;
System.out.println("{bcrypt}" + passwordEncoder.encode("Password"));
Tags:
SpringBoot