title: How Does Apache Shiro Hash Salted Passwords?
body: <p>If I use the <a href="https://shiro.apache.org/command-line-hasher.html" rel="nofollow">Apache Shiro command line tool</a> to generate a password</p>
  
  <pre><code>java -jar shiro-tools-hasher-1.3.1-cli.jar -p -a SHA-512
  </code></pre>
  
  <p>and I use the password <code>password</code> I get </p>
  
  <pre><code>$shiro1$SHA-512$500000$wnjBM5pWpwN5784Aq7i7QA==$IqJ6XdwuKtCNqJCu982CzR6b4A3lnGp2F/WD8tmwVC7SAnOgeuUgtBbJ/ki9FqiIbX/ngF9RJd+5iy971d88cg==
  </code></pre>
  
  <p>The documentation says the hashing is salted by default and defaults to 500k iterations and testing it results in a different password each time so I assume it is.</p>
  
  <p>I can now log in without specifying the salt anywhere though</p>
  
  <pre><code>Subject currentUser = SecurityUtils.getSubject();
  UsernamePasswordToken token = new UsernamePasswordToken("jsmith", "password");
  token.setRememberMe(true);
  currentUser.login(token);
  </code></pre>
  
  <p>The only place I can see is that it must be in the hash. </p>
  
  <p>If we look carefully we can see sections:</p>
  
  <ul>
  <li><code>$shiro1</code> shows it is a Shiro hashed password</li>
  <li><code>$SHA-512</code> shows the algorithm used</li>
  <li><code>$500000</code> shows the number of iterations</li>
  </ul>
  
  <p>The salt is probably after that section or at the end.</p>
  
  <p>Is this a dangerous approach?</p>
  
  <p>Are Apache Shiro exposing too much information here and making it somewhat easier to create an attack?</p>