title: Finding MSBs and LSBs of a string
body: <p>I need to do following operations in Go:</p>
  <ol>
  <li>Concatenate 2 strings</li>
  <li>Compute MD5 hash of the concatenated string (128-bit array)</li>
  <li>Apply an XOR operator to the 64 LSBs and the 64 MSBs on MD5 hash.</li>
  </ol>
  <p>I could compute MD5 hash of the string using &quot;crypto/md5&quot; package, but having trouble implementing step #3.
  Here is the code I came up with which is not correct I think and didn't see any links to get MSBs and LSBs from a string.</p>
  <pre><code>func GenerateHashKey(s1 string, s2 string) string {
      if s1 == &quot;&quot; {
          return &quot;&quot;
      }
  
      data := []byte(s1 + s2)
      md5sum := md5.Sum(data)
      
      // 0: uint32
      lsb := bytes.NewBuffer(md5sum[:9]) // 0-8
      msb := bytes.NewBuffer(md5sum[9:]) // 9-16
      return msb ^ lsb; //This results in an error
  }
  </code></pre>
  <p>Here is a corresponding working Java code that I need to translate to Go.</p>
  <pre><code>//input is a concatenated string
  byte[] str = input.getBytes(&quot;UTF-8&quot;);
  byte[] md5sum = MessageDigest.getInstance(&quot;MD5&quot;).digest(str);
  long lsb =
  ByteBuffer.wrap(md5sum).order(ByteOrder.LITTLE_ENDIAN).getLong(0);
  long msb =
  ByteBuffer.wrap(md5sum).order(ByteOrder.LITTLE_ENDIAN).getLong(8);
  return msb ^ lsb;
  </code></pre>