虹猫y 2017-05-30 16:51 采纳率: 0%
浏览 1243

16轮DES加解密,用MFC写的

代码:
CString DES::EncryptCString(CString str)
{
//USES_CONVERSION;
char szPlaintextData[8192],hexCiphertextAnyLength[16384],bitsCiphertextAnyLength[32768];
memset(szPlaintextData,0,8192);

char* c1=T2A(str);//错误指这儿

memcpy(szPlaintextData,c1,strlen(c1));
EncryptAnyLength(szPlaintextData,strlen(szPlaintextData),0);
memset(hexCiphertextAnyLength,0,16384);
memset(bitsCiphertextAnyLength,0,32768);
int iBitsLen=strlen(szPlaintextData) % 8 == 0 ? strlen(szPlaintextData) << 3 : ((strlen(szPlaintextData)>>3) + 1) << 6;
Bytes2Bits(this->GetCiphertextAnyLength(),bitsCiphertextAnyLength,iBitsLen);
Bits2Hex(hexCiphertextAnyLength,bitsCiphertextAnyLength,iBitsLen);
for(int i=0;i<iBitsLen;i++)
{
    bitsCiphertextAnyLength[i] += 48;
}
CString pwd1=L"";

pwd1.Format(L"%s",A2T(hexCiphertextAnyLength));//错误指这儿

return pwd1;

}
CString DES::DecryptCString(CString str)
{
USES_CONVERSION;
int iLen = 0;

char* c1= T2A(str);//错误指这儿

char bitsCiphertextAnyLength[32768],szCiphertextData[8192];
memset(szCiphertextData,0,8192);
iLen = ((strlen(c1)>>2) + (strlen(c1) % 4 == 0 ? 0 : 1))<<4;
char hexCiphertextAnyLength[16384];
    memset(hexCiphertextAnyLength,0,16384);
    memset(szCiphertextData,0,8192);
    memcpy(hexCiphertextAnyLength,c1,strlen(c1));
    Hex2Bits(hexCiphertextAnyLength,bitsCiphertextAnyLength,iLen);
    Bits2Bytes(szCiphertextData,bitsCiphertextAnyLength,iLen);
DecryptAnyLength(szCiphertextData,iLen>>3,0);
char* cs= this->GetPlaintextAnyLength();
CString pwd1=L"";

pwd1.Format(L"%s",A2T(cs));//错误指这儿

return pwd1;

}
问题:
C:\360CloudUI\DES\DES.cpp(595) : error C2664: 'T2A' : cannot convert parameter 1 from 'class CString' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\360CloudUI\DES\DES.cpp(608) : error C2664: 'void __cdecl CString::Format(const char *,...)' : cannot convert parameter 1 from 'unsigned short [3]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\360CloudUI\DES\DES.cpp(614) : error C2664: 'T2A' : cannot convert parameter 1 from 'class CString' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\360CloudUI\DES\DES.cpp(627) : error C2664: 'void __cdecl CString::Format(const char *,...)' : cannot convert parameter 1 from 'unsigned short [3]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

  • 写回答

4条回答 默认 最新

  • shen_wei 2017-05-31 03:13
    关注
     Header file: AtlBase.h, AtlConv.h
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型