title: Spring Security - Encoded Password Does Not Look Like BCrypt
body: <p>I can't login with the correct details as the program keeps stating that the encoded password does not look like bcrypt. Does anyone know how to solve this? I'm using JDBC authentication.</p>
  
  <p>I have the correct database table as well, with enough space for the encoded password. I'm not sure where it's going wrong.</p>
  
  <p>JSP FORM:
      </p>
  
  <pre><code>                &lt;div class="form-group"&gt;
                      &lt;div class="form-label-group"&gt;
                          &lt;label for="inputUser"&gt;Username: &lt;/label&gt; &lt;input name="username"
                              type="text" path="username" id="inputUser" class="form-control"
                              placeholder="Username" required="required" autofocus="autofocus"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;div class="form-label-group"&gt;
                          &lt;label for="inputPassword"&gt;Password: &lt;/label&gt; 
                          &lt;input name="username" type="password" path="password"
                              id="inputPassword" class="form-control" placeholder="Password"
                              required="required"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;div class="checkbox"&gt;
                          &lt;label&gt; &lt;input type="checkbox" value="remember-me"&gt;
                              Remember Password
                          &lt;/label&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;input type="submit" value="Login"/&gt;
  
              &lt;/form:form&gt;
  </code></pre>
  
  <p>Security Config:</p>
  
  <pre><code>@Autowired
  private DataSource securityDataSource;
  
  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth.jdbcAuthentication().dataSource(securityDataSource).passwordEncoder(passwordEncoder());
  }
  
  @Override
  protected void configure(HttpSecurity http) throws Exception {
  
      http.authorizeRequests().antMatchers("/management/**").authenticated().and().formLogin().loginPage("/login")
              .loginProcessingUrl("/processLogin").defaultSuccessUrl("/management/dashboard").permitAll();
  
      http.exceptionHandling().accessDeniedPage("/access-denied");
  
  }
  
  @Bean
  @Autowired
  public BCryptPasswordEncoder passwordEncoder() {
      return new BCryptPasswordEncoder();
  }
  </code></pre>
  
  <p>Login Controller</p>
  
  <pre><code>@Controller
  public class LoginController {
  
    @Autowired
    private UserServiceImpl userService;
  
  
    @GetMapping("/login")
    public String showLoginForm(Model model) {
  
      User user = new User();
      model.addAttribute("user", user);
  
      return "login";
    }
  
    @PostMapping("/processLogin")
    public String processLogin(@ModelAttribute("user") User user, Model model) {
  
      if (userService.findUser(user.getUsername(), user.getPassword()) != null) {
          return "/management/dashboard";
      } else {
          return "/access-denied";
      }
    }
  }
  </code></pre>
  
  <p>My database: <a href="https://i.stack.imgur.com/jM9FM.png" rel="nofollow noreferrer">here</a></p>