Java Code Examples for org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder#encode()

The following examples show how to use org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder#encode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserService.java    From springboot-seed with MIT License 5 votes vote down vote up
@Transactional
@Override
public boolean add(User user) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
    String crypt = encoder.encode(user.getPassword());
    user.setPassword(crypt);
    return mapper.insertUseGeneratedKeys(user) > 0;
}
 
Example 2
Source File: PasswordUtilsTest.java    From onboard with Apache License 2.0 5 votes vote down vote up
@Test
public void testDigestResultsMatch() {
    BCryptPasswordEncoder digester = PasswordUtils.getBcryptDigestByLevel(0);
    String result1 = digester.encode(STRING);
    String result2 = digester.encode(STRING);
    assertTrue("Digest once should match", digester.matches(STRING, result1));
    assertTrue("Digest twice should match", digester.matches(STRING, result2));
}
 
Example 3
Source File: GatewayApplicationTests.java    From mini-platform with MIT License 5 votes vote down vote up
@Test
public void encodingBCrypt() {
    BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
    //加密时使用
    String hashPassword = passwordEncoder.encode("12345");
    log.info("BCrypt HashPassword: {}", hashPassword);
}
 
Example 4
Source File: BCryptPasswordEncoderTest.java    From learning-code with Apache License 2.0 5 votes vote down vote up
/**
 * 获取密码
 */
@Test
public void testEquals() {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(5);
    String encodePassword = encoder.encode("123456");
    System.out.println(encodePassword);
}
 
Example 5
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 6
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 7
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 8
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 9
Source File: BCryptExample.java    From code-examples with MIT License 4 votes vote down vote up
public String encode(String plainPassword) {
  int strength = 10;
  BCryptPasswordEncoder bCryptPasswordEncoder =
      new BCryptPasswordEncoder(strength, new SecureRandom());
  return bCryptPasswordEncoder.encode(plainPassword);
}
 
Example 10
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 11
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 12
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 13
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 14
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 15
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 16
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 17
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 18
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 19
Source File: BCryptPasswordEncoderMain.java    From Spring-Security-Third-Edition with MIT License 4 votes vote down vote up
public static String encode(String password) {
    BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
    String encodedPassword = encoder.encode(password);
    return encodedPassword;
}
 
Example 20
Source File: SecurityUtils.java    From RuoYi-Vue with MIT License 2 votes vote down vote up
/**
 * 生成BCryptPasswordEncoder密码
 *
 * @param password 密码
 * @return 加密字符串
 */
public static String encryptPassword(String password)
{
    BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
    return passwordEncoder.encode(password);
}