title: System.Security.Cryptography.HMACSHA1 is Com visible. How should I call ComputeHash?
body: <p>I want to create an HMAC SHA1 signature of some text in Microsoft Access</p>
  
  <p>The .net object System.Security.Cryptography.HMACSHA1 is com visible, so I thought I could use that.</p>
  
  <p>I can create the object and set the key, but when I come to call the compute function to get the hash, I am getting the error run time error 5 "Invalid Procedure Call or Argument"</p>
  
  <pre><code>Public Function sign(Key As String, Message As String)
      Dim asc, enc
      Dim MessageBytes() As bytes, HashBytes() As bytes
      Set asc = CreateObject("System.Text.UTF8Encoding")
      Set enc = CreateObject("System.Security.Cryptography.HMACSHA1")
      enc.Key = asc.GetBytes_4(Key)
      MessageBytes = asc.GetBytes_4(Message)
      HashBytes = enc.ComputeHash(MessageBytes)
      sign = EncodeBase64(HashBytes)
      Set asc = Nothing
      Set enc = Nothing
  End Function
  </code></pre>
  
  <p>I copied the Encoding bit from the web and I note there that GetBytes has transmuted into GetBytes_4.  Is this name mangling? and do I need to do something similar to ComputeHash? and if so what (I tried _n where n = 1 to 6 to no avail).</p>
  
  <p>If not What am I doing wrong?</p>