使用CryptoAPI加解密的程序,在XP上运行良好,在2000上加密会错,都不知道什么原因?
server端:
1 导出公私密码对的公钥
2 发送给client端
client端:
1 导入收到的公钥数据得到了正确的HCRYPTKEY句柄
2 加密自己的数据
b = CryptImportKey(hProv, k.pKey, k.len, 0, 0, &hPubKey);
char pass[1024];
memset(pripass,0,1024);
strcpy(pripass,"myprivatepassword");
strcpy(pass,"myprivatepassword");
DWORD dwCount = strlen(pass);
b = CryptEncrypt(hPubKey, 0, TRUE, 0, (BYTE*)pass, &dwCount, 1024);
在XP下返回b为1,说明加密正确,但在2000下返回了0,出错,错误提示为:不正确的项.
有高手知道这是怎么回事吗?