title: convert excel vba Function to c#
body: <p>I have the vba excel function convert my string text to hash.</p>
  <pre><code>Private Function HashString(inputText As String, Optional secretKey = &quot;&quot;) As String
      Dim asc As Object
      Dim enc As Object
      Dim textToHash() As Byte
      Dim SharedSecretKey() As Byte
      Dim bytes() As Byte
      
      If secretKey = &quot;&quot; Then secretKey = inputText
      
      Set asc = CreateObject(&quot;System.Text.UTF8Encoding&quot;)
      Set enc = CreateObject(&quot;System.Security.Cryptography.HMACSHA1&quot;)
  
      textToHash = asc.GetBytes_4(inputText)
      SharedSecretKey = asc.GetBytes_4(secretKey)
      enc.Key = SharedSecretKey
  
      bytes = enc.ComputeHash_2((textToHash))
      HashString = EncodeBase64(bytes)
  End Function
  Private Function EncodeBase64(arrData() As Byte) As String
      Dim objXML As Object
      Dim objNode As Object
      Set objXML = CreateObject(&quot;MSXML2.DOMDocument&quot;)
      Set objNode = objXML.createElement(&quot;b64&quot;)
      objNode.DataType = &quot;bin.base64&quot;
      objNode.nodeTypedValue = arrData
      EncodeBase64 = objNode.Text
  End Function
  </code></pre>
  <p>I want to use this function on other C# platforms to have the same algorithm output,
  How to convert this method to C#?
  Thanks for the help.</p>