title: Compare two hex strings in Java?
body: <p>I am implementing a simple DHT using the Chord protocol in Java. The details are not important but the thing I'm stuck on is I need to hash strings and then see if one hashed string is "less than" another.</p>
  
  <p>I have some code to compute hashes using SHA1 which returns a 40 digit long hex string (of type String in Java) such as:</p>
  
  <pre><code>69342c5c39e5ae5f0077aecc32c0f81811fb8193
  </code></pre>
  
  <p>However I need to be able to compare two of these so to tell, for example that:</p>
  
  <pre><code>0000000000000000000000000000000000000000
  </code></pre>
  
  <p>is less than:</p>
  
  <pre><code>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  </code></pre>
  
  <p>This is the complete range of values as the 40 digit string is actually representing 40 hex numbers in the range 0123456789ABCDEF</p>
  
  <p>Does anyone know how to do this?</p>
  
  <p>Thanks in advance.</p>