title: How to compute hash like MD5(str1+ MD5(str2+ str3))
body: <p>I need to encrypt credentials in order to connect to a remote server.
  From the documentation I found, that the password needs to be hashed like shown below.</p>
  <pre><code>MD5(session + MD5(username+ password))
  </code></pre>
  <p>However I wasn't able to get the same hashed password from C#, as sent from the WebClient to the server.</p>
  <p>I tried several combination, none of those gave me the same result.
  Here is my last approach.</p>
  <pre><code>string EncryptPassword(string UserName, string Password, string SessionId)
          {
              // Password is MD5(sessionId + MD5(login + password))
              // Source: https://www.godo.dev/tutorials/csharp-md5/
              using (MD5 md5 = MD5.Create())
              {
  
                  string credentials = $&quot;{UserName}{Password}&quot;;
                  // Hash credentials first
                  md5.ComputeHash(Encoding.UTF8.GetBytes(credentials));
                  var inputBuffer = Encoding.UTF8.GetBytes(SessionId).ToList();
                  inputBuffer.AddRange(md5.Hash);
                  //var inputBuffer = Encoding.UTF8.GetBytes(SessionId + credentialBuilder.ToString());
  
                  md5.ComputeHash(inputBuffer.ToArray());
  
                  //md5.TransformBlock(inputBuffer, 0, inputBuffer.Length, inputBuffer, 0);
                  //md5.TransformFinalBlock(new byte[0], 0, 0);
  
                  // Get hash result after compute it  
                  byte[] hashedCredentials = md5
                      .Hash;
  
                  StringBuilder strBuilder = new StringBuilder();
                  for (int i = 0; i &lt; hashedCredentials.Length; i++)
                  {
                      //change it into 2 hexadecimal digits  
                      //for each byte  
                      strBuilder.Append(hashedCredentials[i].ToString(&quot;x2&quot;));
                  }
                  return strBuilder.ToString();
              }
          }
  </code></pre>
  <p>I tried with following test credentials:
  username:</p>
  <pre><code>login: TestUser
  password: TestPassword
  session: uu2cO7b7drhxHKItfRpcJ4#qk@230#$R
  </code></pre>
  <p>Valid result: <code>4dfb147da0d2338cb57e05d1b4b21d07</code>  &lt;= this is how it should like with the infos above.</p>
  <p>My result: <code>eb55ef7e70c160ad2dd8fe831a1cf708</code></p>