title: How to correctly encode password using ShaPasswordEncoder?
body: <p>I want to encode a password using <code>ShaPasswordEncoder</code> in my <strong>Spring</strong> app.</p>
  
  <pre><code>ShaPasswordEncoder sha = new ShaPasswordEncoder(256);
  sha.setIterations(1000);
  String hash = sha.encodePassword(password, salt);
  </code></pre>
  
  <p>But I don't what I should put to <code>salt param</code>. Can it be a static phrase (e.g. <em>sT4t1cPhr453</em>), or dynamic string different for every user (e.g. username or user ID)?</p>
  
  <h2>Edit:</h2>
  
  <p>I user custom <code>AuthenticationProvider</code>, so my security context looks like:</p>
  
  <pre><code>&lt;authentication-manager&gt;
     &lt;authentication-provider ref="customAuthenticationProvider" /&gt;
  &lt;/authentication-manager&gt;
  
  &lt;beans:bean id="customAuthenticationProvider" class="com.app.cloud.auth.CustomAuthenticationProvider"&gt;
  
  @Component("customAuthenticationProvider")
  public class CustomAuthenticationProvider implements org.springframework.security.authentication.AuthenticationProvider {
  
      @Autowired
      private AuthService authService;
  
      @Override
      public Authentication authenticate(Authentication authentication)
              throws AuthenticationException,BadCredentialsException {
      //...
      }
  
      @Override
      public boolean supports(Class&lt;?&gt; authentication) {
          return authentication.equals(UsernamePasswordAuthenticationToken.class);
      }
  }
  </code></pre>