1.login into telecom sms gateway
java
int len = 42;
buf = new byte[len];
TypeConvert.int2byte(len, buf, 0); //00 00 00 2a
TypeConvert.int2byte(1, buf, 4); //00 00 00 2a
System.arraycopy(clientId.getBytes(), 0, buf, 12, clientId.length());
if(shared_Secret != null)
len = clientId.length() + 17 + shared_Secret.length();
else
len = clientId.length() + 17;
byte tmpbuf[] = new byte[len];
int tmploc = 0;
System.arraycopy(clientId.getBytes(), 0, tmpbuf, 0, clientId.length());
tmploc = clientId.length() + 7;
if(shared_Secret != null)
{
System.arraycopy(shared_Secret.getBytes(), 0, tmpbuf, tmploc, shared_Secret.length());
tmploc += shared_Secret.length();
}
String tmptime = "0008080808";
System.arraycopy(tmptime.getBytes(), 0, tmpbuf, tmploc, 10);
SecurityTools.md5(tmpbuf, 0, len, buf, 20);//20-35 md5=16位
buf[36] = (byte)loginMode; //36
TypeConvert.int2byte(0x7b4da8, buf, 37);//37 38 39 40
buf[41] = (byte)version;//41
c++
seqnoIndex++;
int msglen = 42;
bb = new byte[msglen];
memset(bb,0,42);
bb_putInt(msglen);//00 00 00 2a
bb_putInt(1);//00 00 00 01
bb_putInt(seqnoIndex);//00 00 00 01
//8位账户
bb_put(StringtoBytes(new byte[8],8, user),8);
//16位加密密码
char buftemp[42]="";
int tmploc=0;
strcpy(buftemp,user);tmploc+=strlen(user)+7;
strcpy(buftemp+tmploc,passwd);tmploc+=strlen(passwd);
//"0008080808"
strcpy(buftemp+tmploc,"0008080808");tmploc+=10;
char bufout[42]="";
MD5Calc((unsigned char *)bufout,(unsigned char *)buftemp,tmploc);
bb_put(StringtoBytes(new byte[16],16, bufout),16);
bb_put((byte)3);//loginMode //36
bb_putInt(0x7b4da8);//37 38 39 40
bb_put((byte)32);//version
2.login into china mobile's sms gateway
c++
int msglen = 29;
bb = new byte[msglen];
memset(bb,0,29);
bb_putInt(msglen);
bb_putInt(0);
bb_putInt(seqnoIndex++);
bb_put((byte)0);
bb_put(StringtoBytes(new byte[8],8, user),8);
bb_put(StringtoBytes(new byte[8],8, passwd),8);
java
int len = 42;
buf = new byte[len];
TypeConvert.int2byte(len, buf, 0); //00 00 00 2a
TypeConvert.int2byte(1, buf, 4); //00 00 00 2a
System.arraycopy(clientId.getBytes(), 0, buf, 12, clientId.length());
if(shared_Secret != null)
len = clientId.length() + 17 + shared_Secret.length();
else
len = clientId.length() + 17;
byte tmpbuf[] = new byte[len];
int tmploc = 0;
System.arraycopy(clientId.getBytes(), 0, tmpbuf, 0, clientId.length());
tmploc = clientId.length() + 7;
if(shared_Secret != null)
{
System.arraycopy(shared_Secret.getBytes(), 0, tmpbuf, tmploc, shared_Secret.length());
tmploc += shared_Secret.length();
}
String tmptime = "0008080808";
System.arraycopy(tmptime.getBytes(), 0, tmpbuf, tmploc, 10);
SecurityTools.md5(tmpbuf, 0, len, buf, 20);//20-35 md5=16位
buf[36] = (byte)loginMode; //36
TypeConvert.int2byte(0x7b4da8, buf, 37);//37 38 39 40
buf[41] = (byte)version;//41
c++
seqnoIndex++;
int msglen = 42;
bb = new byte[msglen];
memset(bb,0,42);
bb_putInt(msglen);//00 00 00 2a
bb_putInt(1);//00 00 00 01
bb_putInt(seqnoIndex);//00 00 00 01
//8位账户
bb_put(StringtoBytes(new byte[8],8, user),8);
//16位加密密码
char buftemp[42]="";
int tmploc=0;
strcpy(buftemp,user);tmploc+=strlen(user)+7;
strcpy(buftemp+tmploc,passwd);tmploc+=strlen(passwd);
//"0008080808"
strcpy(buftemp+tmploc,"0008080808");tmploc+=10;
char bufout[42]="";
MD5Calc((unsigned char *)bufout,(unsigned char *)buftemp,tmploc);
bb_put(StringtoBytes(new byte[16],16, bufout),16);
bb_put((byte)3);//loginMode //36
bb_putInt(0x7b4da8);//37 38 39 40
bb_put((byte)32);//version
2.login into china mobile's sms gateway
c++
int msglen = 29;
bb = new byte[msglen];
memset(bb,0,29);
bb_putInt(msglen);
bb_putInt(0);
bb_putInt(seqnoIndex++);
bb_put((byte)0);
bb_put(StringtoBytes(new byte[8],8, user),8);
bb_put(StringtoBytes(new byte[8],8, passwd),8);