title: spring security encode password with bcrypt algorithm
body: <p>i get something strange... in spring security for encode password..</p>
  
  <p>i am trying to change my password and save it to database..but i always get error because defferent string..</p>
  
  <p>like this..</p>
  
  <p>in controller ..</p>
  
  <pre><code>println "password  = "+oldPass
  println "password 1 = "+springSecurityService.encodePassword('password')
  println "password 2 = "+springSecurityService.encodePassword('password')
  println "password  = "+springSecurityService.encodePassword(oldPass)
  </code></pre>
  
  <p>and this ooutput</p>
  
  <p><a href="https://i.stack.imgur.com/FkVYy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FkVYy.png" alt="enter image description here"></a></p>
  
  <p>its strange...everytime i encodePassword, i will get different result.</p>
  
  <p>i am using grails 3.0.5 and use bcrypt algorithm</p>
  
  <pre><code>grails.plugin.springsecurity.password.algorithm = 'bcrypt'
  </code></pre>
  
  <p>i put this line in application.groovy</p>
  
  <p>like this</p>
  
  <pre><code>    // Added by the Spring Security Core plugin:
  grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.akiong.security.User'
  grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.akiong.security.UserRole'
  grails.plugin.springsecurity.authority.className = 'com.akiong.security.Role'
  grails.plugin.springsecurity.requestMap.className = 'com.akiong.security.RequestMap'
  grails.plugin.springsecurity.securityConfigType = 'Requestmap'
  grails.plugin.springsecurity.controllerAnnotations.staticRules = [
      '/':                ['permitAll'],
      '/error':           ['permitAll'],
      '/index':           ['permitAll'],
      '/index.gsp':       ['permitAll'],
      '/shutdown':        ['permitAll'],
      '/assets/**':       ['permitAll'],
      '/**/js/**':        ['permitAll'],
      '/**/css/**':       ['permitAll'],
      '/**/images/**':    ['permitAll'],
      '/**/favicon.ico':  ['permitAll']
  ]
  grails.plugin.springsecurity.password.algorithm = 'bcrypt'
  </code></pre>
  
  <p>but when i create an user account with bootstrap and save it to database..
  then i login ...it run with correctly..</p>
  
  <p><a href="https://i.stack.imgur.com/LzD1i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LzD1i.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/OhK9L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OhK9L.png" alt="enter image description here"></a></p>