title: Spring boot password Bcrypt
body: <p>i have springboot rest code to register some user. and i encode it using bycrpt encoder. the code is like this below</p>
  
  <pre><code>@RequestMapping(value="/customer/new", method=RequestMethod.POST)
      public Customer newCustomer (@RequestBody Customer customer){
              customer.setPassword(new BCryptPasswordEncoder().encode(customer.getPassword()));
          return customerservice.saveCustomer(customer);
          }
  </code></pre>
  
  <p>so it successfull to store the password with encoded password
  somthing like this
  $2a$10$f25IxR/b7wNJBl7Zi.zEMOzpR2nDEw7IJwR3tv/BVKsKJRAtDe1Mq</p>
  
  <p>so i make the login rest controller like this below</p>
  
  <pre><code>@RequestMapping(value = "customer/login", method = RequestMethod.POST)
          public String login(@RequestBody Customer login) throws ServletException {
  
              String jwtToken = "";
  
              if (login.getUsername()== null || login.getPassword()== null) {
                  throw new ServletException("Please fill in username and password");
              }
  
              String username = login.getUsername();
              String password = new BCryptPasswordEncoder().encode(login.getPassword());
  
  
              Customer customer = customerservice.findByusername(username);
  
              if (customer == null) {
                  throw new ServletException("Username not found.");
              }
  
              String pwd = customer.getPassword();
  
              if (!password.equals(pwd)) {
                  throw new ServletException("Invalid login. Please check your name and password.");
              }
  </code></pre>
  
  <p>the login rest controller get username from input and get the password from user input. and i try to encode the password so it can be return as Bcrypt encoded password and match the password that store before.</p>
  
  <p>but it doesnt match. i can get the same password encoded. how to resolve that?
  im new using springboot rest</p>