martythegreat
asked on
Problems with the Crypt functions.
I am trying to encrypt small strings of data. I am trying to use the Crypt functions. I think the sequence that I use this functions is as follows -
Encryption
1/ CryptAcquireContext
2/ CryptGenKey
3/ CryptCreateHash
4/CryptHashData
5/ CryptEncrypt
Question 1/ Should ever one of these items be destroyed.
Question 2/ Is there a way that I can not use the Hash key, as it is not all that necessary. The Hash key is the digital signature??
Decryption
1/ call the CryptDecrypt function.
Question3 - How do you use the same key for the decryption as the encryption. When the application has being exited, and entered at a different date. Is the "cryptographic key from a key blob " involved.
N. B Question 4 - When I try to use the CryptAcquireContext function, there is a big problem. I used the code
#include <wincrypt.h>
HCRYPTPROV hProv = 0;
if(!CryptAcquireContext(&h Prov, NULL, NULL, PROV_RSA_FULL, 0))
AfxMessageBox("ERROR");
I get the error message, i.e. the context is not being created.
I am using Visual C++ version 5 professional edition.
The operating system that I am using is Windows 95 on a Fujitsu machine. In the help files, it says that this function applies to windows 95 OSR2, seen as I am using win95 with fujitsu hardware, it should satisfy this requirment.
In the wincrypt.h there is a #if statement who*s braces enclose the entire page of code -
#if(_WIN32_WINNT >= 0x0400)
If the OS is NT v4, or greater, the expression evaluates to false. By commenting out this line, the page of code is executed, i.e. the HCRYPTPROV hProv = 0 declaration is recognized, It wasn*t before the #if was commented out.
I also tried the same thing on an NT machine that was version 4, and it didn*t work either. So what am I doing wrong, or is it possible to use these function at all in the environment that I using them.
Question 5 - Is there another way of doing encryption in VC. The level of encryption that I require is quite low.
Encryption
1/ CryptAcquireContext
2/ CryptGenKey
3/ CryptCreateHash
4/CryptHashData
5/ CryptEncrypt
Question 1/ Should ever one of these items be destroyed.
Question 2/ Is there a way that I can not use the Hash key, as it is not all that necessary. The Hash key is the digital signature??
Decryption
1/ call the CryptDecrypt function.
Question3 - How do you use the same key for the decryption as the encryption. When the application has being exited, and entered at a different date. Is the "cryptographic key from a key blob " involved.
N. B Question 4 - When I try to use the CryptAcquireContext function, there is a big problem. I used the code
#include <wincrypt.h>
HCRYPTPROV hProv = 0;
if(!CryptAcquireContext(&h
AfxMessageBox("ERROR");
I get the error message, i.e. the context is not being created.
I am using Visual C++ version 5 professional edition.
The operating system that I am using is Windows 95 on a Fujitsu machine. In the help files, it says that this function applies to windows 95 OSR2, seen as I am using win95 with fujitsu hardware, it should satisfy this requirment.
In the wincrypt.h there is a #if statement who*s braces enclose the entire page of code -
#if(_WIN32_WINNT >= 0x0400)
If the OS is NT v4, or greater, the expression evaluates to false. By commenting out this line, the page of code is executed, i.e. the HCRYPTPROV hProv = 0 declaration is recognized, It wasn*t before the #if was commented out.
I also tried the same thing on an NT machine that was version 4, and it didn*t work either. So what am I doing wrong, or is it possible to use these function at all in the environment that I using them.
Question 5 - Is there another way of doing encryption in VC. The level of encryption that I require is quite low.
Question 5 - You could always write your own encryption/decryption scheme. It would probably provide and interesting challenge if you have nothing else to do :-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.