BOOL  CTVMSKEncrypt::Decrypt(CString strToDecrypt,CString strDecryptParam,CString &strDecryptResult) 
{
strDecryptResult.Empty(); int nLen =strToDecrypt.GetLength();
int nPLen =strDecryptParam.GetLength();

if(strToDecrypt.GetLength() != 100)
{
return FALSE;
} int nRealPassLen = strToDecrypt.GetAt(60) - 65;
int nRealParaLen = strToDecrypt.GetAt(61) - 65; if(nRealParaLen != nPLen)
{
return FALSE;
} for(int i=0; i<nPLen;i++)
{
if(strToDecrypt[i+62]-1 != strDecryptParam[i])
{
return FALSE;
} if(::IsDBCSLeadByte(strDecryptParam[i]))
{
i++; if(strToDecrypt[i+62] != strDecryptParam[i])
{
return FALSE;
}
}
} for(i=0;i<nRealPassLen;i++)
{
char ch = strToDecrypt.GetAt(i);

char ch1 = strDecryptParam.GetAt(i%nPLen);
int  nBit   = i%8;

int  nMask  = 1 << nBit;

int  nRes = ch1&nMask;

if(nRes > 0)
{
ch -= 2;
}
else
{
ch -= 1;
} strDecryptResult.Insert(i,ch); if(::IsDBCSLeadByte(ch))
{
i++;
strDecryptResult.Insert(i,strToDecrypt.GetAt(i));
}
} return TRUE;
}

解决方案 »

  1.   

    用前还复补上一宏
    USES_CONVERSION;
    _com_util::ConvertStringToBSTR()
      

  2.   

    晕,
    BOOL  CTVMSKEncrypt::Decrypt(BSTR bstrToDecrypt,BSTR bstrDecryptParam,BSTR &bstrDecryptResult) 
    {
     USES_CONVERSION;
     CString strDecryptResult;
     CString strToDecrypt = _com_util::ConvertBSTRToString(bstrToDecrypt);
     CString strDecryptParam= _com_util::ConvertBSTRToString(bstrDecryptParam);
    ....... bstrDecryptResult = _com_util::ConvertStringToBSTR(strDecryptResult);}
      

  3.   

    可是在ATL里面不能用CSTRING 啊 ?大哥 请教了
      

  4.   

    #include<altstr.h>就可以在ATL里用CString了