0
unsigned char * BUFFER_PTR;
CRYPT_CONTEXT cryptContext;
// Initialize the buffer
BUFFER_PTR = (unsigned char *) malloc(sizeof(char) * BUFFER_SIZE);
memset(BUFFER_PTR, 'X', BUFFER_SIZE);
//Initialize crytplib
cryptInit();
// create encryption context
cryptCreateContext(&cryptContext, CRYPT_UNUSED, CRYPT_ALGO_ELGAMAL);
cryptSetAttributeString(cryptContext, CRYPT_CTXINFO_LABEL, KEY_ID, strlen(KEY_ID));
cryptGenerateKey(cryptContext);
/* ERROR >>>*/ cryptEncrypt(cryptContext, BUFFER_PTR, BUFFER_SIZE); /* this line fails and I don't know why :-(*/
請更具體一些。當你說一行失敗時,它返回什麼錯誤代碼?你有沒有在CryptLib文檔中查找錯誤代碼? – crazyscot 2011-05-10 12:17:15