title: Converting int/long to 64-bit binary
body: <p>I'm looking for a better way to convert an int to 64 bit binary represented as String. Right now I'm converting int to 32bit binary and then adding 32 zeroes in front of it. I'm implementing SHA-1 and I need that int to be 64bit binary.</p>
  
  <pre><code>private static String convertIntTo64BitBinary(int input) {
      StringBuilder convertedInt = new StringBuilder();
      for(int i = 31; i &gt;= 0; i--) { // because int is 4 bytes thus 32 bits
          int mask = 1 &lt;&lt; i;
          convertedInt.append((input &amp; mask) != 0 ? "1" : "0");
      }
      for(int i = 0; i &lt; 32; i++){
          convertedInt.insert(0, "0");
      }
      return convertedInt.toString();
  }
  </code></pre>
  
  <p>EDIT 1:
  Unfortunately this doesn't work:</p>
  
  <pre><code>    int messageLength = message.length();
      String messageLengthInBinary = Long.toBinaryString((long) messageLength);
  
  messageLengthInBinary is "110"
  </code></pre>
  
  <p>EDIT 2:
  To clarify:
  I need the string to be 64 chars long so need all the leading zeros.</p>