Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7693389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:04:37+00:00 2026-05-31T21:04:37+00:00

I have a class of encryption that was developed in Microsoft Visual C++ 6.0,

  • 0

I have a class of encryption that was developed in Microsoft Visual C++ 6.0, and it is working properly. I migrated the code to Microsoft Visual Studio 2008, this class is working, but with a different behavior.

When I pass a specific string for encryption, the encryption result generated in the compiled code in Visual C + + 6.0 is different than in Visual Studio 2008, and it should not happen.

Can anyone help me understand why this is happening?

Cryptography functions of the Windows Services used:

HCRYPTPROV hProv;
HCRYPTHASH hHash;
HCRYPTHASH hKey;
CString strDataKey;
DWORD dwSize;
DWORD dwSizeEncrypted;
BYTE * aszEncryptedBuffer;

………(Other codes…..)…….

CryptAcquireContext (& hProv, NULL, MS_STRONG_PROV, PROV_RSA_FULL, 0);

CryptCreateHash (hProv, CALG_MD5, 0, 0, & hHash);

CryptHashData (hHash, (const unsigned char *) strDataKey, dwSize, 0);

CryptDeriveKey (hProv, CALG_RC2, hHash, CRYPTDERIVEKEY_FLAG, & hKey);

aszEncryptedBuffer = new BYTE[dwSizeEncrypted];

memcpy(aszEncryptedBuffer,"Data to be encrypted",dwSize);

CryptEncrypt (hKey, 0, TRUE, 0, aszEncryptedBuffer, & dwSize, dwSizeEncrypted);

thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:04:39+00:00Added an answer on May 31, 2026 at 9:04 pm
    CryptHashData (hHash, (const unsigned char *) strDataKey, dwSize, 0);
    

    That’s a killer cast you’ve got there. CString has a conversion operator for const TCHAR* but not for const unsigned char*. This tends to work by accident but you’ll easily run out of luck. You cannot convert from one string representation to another with a cast. For example when the CString stores a Unicode string. It does with default VS2008 project settings. Project + Properties, General, Character Set option. Also consider wcstombs() or WideCharToMultiByte() to make a real conversion. The code page you convert to can and will affect the resulting string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method in my static Encryption class that looks like this: public
I have a .NET class that implements TripleDES encryption and decryption. The code is
I have this code for AES encryption, can some one verify that this code
I have an unmanaged assebmly (encryption functionality) that a VB.NET (2.0) installer class uses
I have a class that takes a string in this format: 000067000000000012620060324b38e2cab3353 , encrypts
I am using Jasypt for encryption. This is my code: public class Encryptor {
I have class method that returns a list of employees that I can iterate
I have class with a member function that takes a default argument. struct Class
I have been using the encryption class of codeigniter (PHP framework) for a while
I have a PHP program that encrypts a PDF file into .xxx file this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.