title: How to MD5 encrypt using Challenge Key
body: <p>I am trying to establish a connection to a Server using MD5 Authentication.
  The server returns me the challenge key. 
  How can I use it to encrypt my password and send it back to the server.
  The encryption method currently I know needs Password Hash, Salt Key, and VI Code.
  How Can I make it .</p>
  
  <pre><code>    static readonly string PasswordHash = "PasswordHash";
      static readonly string SaltKey = "SaltKey";
      static readonly string VIKey = "@1B2c3D4e5F6g7H8";
  
      public static string Encrypt(string plainText)
      {
          byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
  
          byte[] keyBytes = new Rfc2898DeriveBytes(PasswordHash, Encoding.ASCII.GetBytes(SaltKey)).GetBytes(256 / 8);
          var symmetricKey = new RijndaelManaged() { Mode = CipherMode.CBC, Padding = PaddingMode.Zeros };
          var encryptor = symmetricKey.CreateEncryptor(keyBytes, Encoding.ASCII.GetBytes(VIKey));
  
          byte[] cipherTextBytes;
  
          using (var memoryStream = new MemoryStream())
          {
              using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
              {
                  cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
                  cryptoStream.FlushFinalBlock();
                  cipherTextBytes = memoryStream.ToArray();
                  cryptoStream.Close();
              }
              memoryStream.Close();
          }
          return Convert.ToBase64String(cipherTextBytes);
  </code></pre>