void CSmsCmpp::EncodeConnect(const long& nSecID,const string& sSrcAddr, const string& sPwd, const string& sUser, BYTE nVer)
{
m_smHeader.lCommandLength = 39;
m_smHeader.lCommandId = CMPP_CONNECT;
m_smHeader.lSequenceNumber = nSecID;
EncodeHeader();
string sAuthName;
if(int(sUser.size())>0) {
sAuthName = sUser.c_str();
}
else {
sAuthName = sSrcAddr.c_str();
}
AppendOct(m_Body,(PBYTE)sAuthName.c_str(),6);
vector<BYTE> vAuth;
std::copy(sAuthName.begin(),sAuthName.end(),back_inserter(vAuth));
for(int i=0;i<9;i++) vAuth.push_back(0x00);
std::copy(sPwd.begin(),sPwd.end(),back_inserter(vAuth));
string sStamp = GetCurTime();
std::copy(sStamp.begin(),sStamp.end(),back_inserter(vAuth));
char src[400];
memset(src,0,400);
std::copy(vAuth.begin(),vAuth.end(),src);
PBYTE temp = new BYTE[17];
memset(temp,0,17);
DWORD dwSize;
CryptMD5Hash((PBYTE)src,int(vAuth.size()),temp,dwSize);
ostringstream oss;
oss<<"发送连接包!";
AppendOct(m_Body,(PBYTE)temp,16); //ICP认证码
delete[] temp;
AppendInt(m_Body,nVer);
DWORD lTimeStamp = atoi(sStamp.c_str());
lTimeStamp = htonl(lTimeStamp);
AppendOct(m_Body,(PBYTE)&lTimeStamp,4);
}
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073