// make key
memset(key_des,0,9);
sprintf((char*)temp,"%s",W2A(keystring));
if(len_keystring>=iSize)
memcpy(key_des,temp,iSize);
else
memcpy(key_des,temp,len_keystring);
sprintf((char*)temp,"%s",W2A(content));
memset(tempout,0,4096);
for(i=0,j=0;len_instring>0;len_instring-=iSize*2,i+=iSize*2,j+=iSize)
{
HstrToChr((unsigned char*)(temp+i),iSize*2,res);
crypt_decrypt(je,res,key_des,des);
des[8]='\0';
memcpy(tempout+j,des,iSize);
}
*outstring=A2BSTR((char*)tempout);
方法引數(BSTR mark, BSTR in, BSTR keystring, BSTR *outstring) keystring是key content是資料
我修改成C++(QT)后 , content和keystring是QString
// make key
memset(key_des,0,9);
char* ch_keystring;
QByteArray ba_in_keystring = keystring.toLatin1();
ch_keystring=ba_keystring.data();
char* ch_content;
QByteArray ba_content = content.toLatin1();
ch_content=ba_in.data();
sprintf((char*)temp,"%s",ch_keystring);
if(len_keystring>=iSize)
memcpy(key_des,temp,iSize);
else
memcpy(key_des,temp,len_keystring);
sprintf((char*)temp,"%s", ch_content);
memset(tempout,0,4096);
for(i=0,j=0;len_instring>0;len_instring-=iSize*2,i+=iSize*2,j+=iSize)
{
HstrToChr((unsigned char*)(temp+i),iSize*2,res);
CryptDecrypt(je,res,key_des,des);
des[8]='\0';
memcpy(tempout+j,des,iSize);
}
qDebug()<<"tempout"<<(char*)tempout;
解碼出來結果
|J702414|2018??08??21??|???????????????????????|
中文為問號,英文和數字正常
uj5u.com熱心網友回復:
請問下問題出在哪?uj5u.com熱心網友回復:
看輸出視窗的字符編碼是否能列印中文字符。uj5u.com熱心網友回復:

把每個char都0xFF16進制列印出來。對比
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/39478.html
標籤:C++ 語言
下一篇:第一次做C簡單的猜數游戲
