title: C++ md5 not matching vb.net md5
body: <p>the string is found in a text file testx.txt
  the string is Nw[v|YK it contains utf8 characters i believe</p>
  <pre><code>ifstream infile(&quot;testx.txt&quot;);
  
    if (infile.good())
    {
      string sLine;
      getline(infile, sLine);
  char* cx = const_cast&lt;char*&gt;(sLine.c_str());
      string a2 = md5.digestString(cx);
      cout &lt;&lt; a2 &lt;&lt; endl;
    }
  </code></pre>
  <p>i have been doing exactly as my vb.net code and reading it as a string then trying to md5 it ... is it because its utf8? what do i do to read it as a string and get the proper md5?</p>
  <p>vb.net md5 code</p>
  <pre class="lang-vb prettyprint-override"><code>Public Function GetIRC7PWD(source As String)
          Dim md5Hash As MD5 = MD5.Create()
          Dim data As Byte() = md5Hash.ComputeHash(Encoding.Default.GetBytes(source))
          Dim sBuilder As New StringBuilder()
          Dim i As Integer
          For i = 0 To data.Length - 1
              sBuilder.Append(data(i).ToString(&quot;x2&quot;))
          Next i
          Return sBuilder.ToString()
  
      End Function
  
  End Module
  </code></pre>
  <p>text file can be found @ <a href="https://tha-row.net/testx.txt" rel="nofollow noreferrer">https://tha-row.net/testx.txt</a></p>
  <pre class="lang-vb prettyprint-override"><code> Dim lines() As String = IO.File.ReadAllLines(&quot;d:\\testx.txt&quot;)
          Dim line As String = lines(0)
          Dim a1 As String = GetIRC7PWD(line)
  </code></pre>
  <p>a1 returns the proper hash of 3be255619a53ec2af553e0cae9606a9a</p>
  <p>now i have a md5 code for c++</p>