CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2007
    Posts
    8

    How does this translate to c++

    Hi all,

    How does this translate to c++:

    string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
    HashAlgorithm XHash = HashAlgorithm.Create("MD5");byte[] keyArray = XHash.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
    XHash.Clear();
    TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
    tdes.Key = keyArray;
    tdes.Mode = CipherMode.ECB;
    tdes.Padding = PaddingMode.PKCS7;

    This is what I did but i am not sure if its correct because I didnt do the UTF8Encoding part.


    TCHAR szKey[] = _T("Key");
    DWORD pwlen = _tcslen(szKey);
    result = CryptCreateHash(hProv,CALG_MD5,0,0,&hHash);
    result = CryptHashData(hHash,(BYTE *)szKey,pwlen,0);
    result = CryptDeriveKey(hProv,CALG_3DES,hHash,0,&hKey);
    BYTE PadMode = CRYPT_MODE_ECB;
    result = CryptSetKeyParam(hKey, PKCS5_PADDING, &PadMode, 0);


    Please help me clarify things.

    Thanks,
    Jayjay

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: How does this translate to c++

    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured