c# - CryptEncrypt gives different results for different languages -


When I run this code in C ++ (shown), in C # or VB6, I have a crypt encryption in pbBuffer Get different results for! I can think that the only thing CryptEncrypt is language based or the parameters are wrong for other tasks. What would be the other reason? I am providing wrong parameters to CryptDeriveKey

  What will happen then? (CryptAcquireContext (& amp; hProv; zero, zero, PROV_RSA_FULL, 0)} {cryptCreateHash (hProv, CALG_MD5, 0, 0, & hHash)} {if (CryptHashData (hHash, (byte *) szLocalPassword, _tcslen (szLocalPassword), 0)) {If CryptDeriveKey (hProv, CALG_RC4, hHash, CRYPT_EXPORTABLE, & HKEY)} {dwLength = sizeof (TCHAR) * _tcslen (sUnencryptedString); Byte * pbBuffer = (byte *) mLok (dwLength); If (pbBuffer! = NULL) {// Convert TCHAR BYTE four c_szText [128] = {0}; // any SIZE_T then = wcslen (sUnencryptedString) + 1; Wcstombs (c_szText, sUnencryptedString, therefore); Memcpy (pbBuffer, c_szText, dwLength); If the text after "itemprop =" text (CryptEncrypt (HKEY, 0, right, 0, pbBuffer, & dwLength, dwLength))    

This is a VB code that indicates how to pass the correct information to the crypto API to encrypt a string in VB6. Hopefully anyone can use this information! LResult = CryptHashData (hHash, bKeyRoot (0), lane (sKeyRoot), 0) as the bKeyRoot () byte bKeyRoot = StrConv (sKeyRoot, vbFromUnicode) Dim bText () byte bText = StrConv (sText, as vbFromUnicode) lResult = CryptEncrypt (lKey, 0, 1, 0, bText (0), lClear, lData) sText = StrConv (bText, vbUnicode) < / pre>

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -