title: Symfony2 Security: Using encryption settings in code
body: <p>I use security.yml to configure password encryption:</p>
  
  <pre><code>encoders:
      Acme\UserBundle\Entity\User:
          algorithm: bcrypt
          cost: 10
  </code></pre>
  
  <p>Now I want to update user password in my User Entity so somewhere in Entity\User.php I should have something like:</p>
  
  <pre><code>$this-&gt;password = password_hash($password, PASSWORD_DEFAULT, ['cost' =&gt; 10]);
  </code></pre>
  
  <p>But let's imagine that sometimes someone will decide to change for example encryption cost value to 20 and will update security.yml. It's easy to forget about custom encryption code.</p>
  
  <p>Can I use settings from security.yml in my code to make solution more generalized and friendly for changes?</p>