- class TAesClass
- {
- public:
- TAesClass();
- ~TAesClass();
- void InitializePrivateKey(DWORD KeySize,UCHAR *KeyBytes); //AES 密钥初始化
- DWORD OnAesEncrypt(LPVOID InBuffer,DWORD InLength,LPVOID OutBuffer); //AES 加密数据
- DWORD OnAesUncrypt(LPVOID InBuffer,DWORD InLength,LPVOID OutBuffer); //AES 解密数据
- private:
- Aes * m_lpAes;
- };
我最近编写加密,解密算法,上面的代码是需要调用的类
TAesClass *aes = new TAesClass; aes->InitializePrivateKey
(16, "xcy"); 当我这样去编写代码的时候,编译代码时,就会出现:invalid conversion from 'const char*' to 'UCHAR*' 因为"xcy"参数是char类型,也就是char *类型,而api需要的是 UCHAR*类型,因此导致编译出错。经过对C语言的摸索,找到了解决的方法: 先定义UCHAR类型变量,然后定义UCHAR*类型指针,使用指针,指向变量即可。代码如下:
- TAesClass *aes = new TAesClass;
- UCHAR key[1024] = "xcy";
- UCHAR *p = key;
- aes->InitializePrivateKey(16, p);
阅读(4778) | 评论(0) | 转发(0) |