title: how to encode pass with sha1 and Base64?
body: <p>I need provide hashing password with sha1 and Base64 like next:</p>
  
  <pre><code>base64(sha1(password))
  </code></pre>
  
  <p>here is what i tried for:</p>
  
  <pre><code>private static String convertToHex(byte[] data) { 
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i &lt; data.length; i++) { 
          int halfbyte = (data[i] &gt;&gt;&gt; 4) &amp; 0x0F;
          int two_halfs = 0;
          do { 
              if ((0 &lt;= halfbyte) &amp;&amp; (halfbyte &lt;= 9)) {
                  buf.append((char) ('0' + halfbyte));
              }
              else {
                  buf.append((char) ('a' + (halfbyte - 10)));
              }
              halfbyte = data[i] &amp; 0x0F;
          } while(two_halfs++ &lt; 1);
      } 
      return buf.toString();
  } 
  
  
  public static String SHA1(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
      MessageDigest md = MessageDigest.getInstance("SHA-1");
      md.update(password.getBytes("iso-8859-1"), 0, password.length());
      byte[] sha1hash = md.digest();
      return convertToHex(sha1hash);
  }
  </code></pre>
  
  <p>and than :</p>
  
  <pre><code>String encodedPass = Base64.encodeToString(password.getBytes(), Base64.DEFAULT);
  </code></pre>
  
  <p>but this doesn't work correctly...
  Maybe there some mistake or some much easier way to do it?  </p>