title: Java calculate hex representation of a SHA-1 digest of a String
body: <p>I'm storing the user password on the db as a sha1 hash.</p>
  
  <p>Unfortunately I'm getting strange answers.</p>
  
  <p>I'm storing the string as this:</p>
  
  <pre><code>MessageDigest cript = MessageDigest.getInstance("SHA-1");
                cript.reset();
                cript.update(userPass.getBytes("utf8"));
                this.password = new String(cript.digest());
  </code></pre>
  
  <p>I wanted something like this --></p>
  
  <p>aff --> "0c05aa56405c447e6678b7f3127febde5c3a9238"</p>
  
  <p>rather than</p>
  
  <p>aff --> �V@\D~fx����:�8</p>