title: CryptEncrypt gives different results for different languages
body: <p>When I run this code in C++ (shown), C#, or VB6, I get different results for pbBuffer in CryptEncrypt! The only thing I can think of is CryptEncrypt is language-based or the parameters are wrong for the other functions. What other reason would this happen? Am I passing the wrong parameters to CryptDeriveKey?</p>
  
  <pre><code>if (CryptAcquireContext(&amp;hProv, NULL, NULL, PROV_RSA_FULL, 0))     
  {   
      if (CryptCreateHash(hProv, CALG_MD5, 0, 0, &amp;hHash))        
      {   
          if (CryptHashData(hHash, (BYTE *)szLocalPassword, _tcslen(szLocalPassword), 0))            
          {
              if (CryptDeriveKey(hProv, CALG_RC4, hHash, CRYPT_EXPORTABLE, &amp;hKey))                   
              {   
                  dwLength = sizeof(TCHAR)*_tcslen(sUnencryptedString);                      
                  BYTE *pbBuffer = (BYTE *)malloc(dwLength);                     
                  if (pbBuffer != NULL)                      
                  {   
                  // Convert TCHAR to BYTE
                  char c_szText[128] = {0};       // Any char
                  SIZE_T so = wcslen(sUnencryptedString) + 1;
                  wcstombs(c_szText, sUnencryptedString, so);
                  memcpy(pbBuffer, c_szText, dwLength);
  
                  if (CryptEncrypt(hKey, 0, TRUE, 0, pbBuffer, &amp;dwLength, dwLength))                         
  </code></pre>