@@ -77,6 +77,67 @@ private String genSig(String identifier, long expire, byte[] userbuf) {
7777 return (new String (Base64URL .base64EncodeUrl (Arrays .copyOfRange (compressedBytes ,
7878 0 , compressedBytesLength )))).replaceAll ("\\ s*" , "" );
7979 }
80+ public byte [] genUserBuf (String account ,long dwAuthID , long dwExpTime ,
81+ long dwPrivilegeMap ,long dwAccountType ){
82+ //视频校验位需要用到的字段
83+ /*
84+ cVer unsigned char/1 版本号,填0
85+ wAccountLen unsigned short /2 第三方自己的帐号长度
86+ buffAccount wAccountLen 第三方自己的帐号字符
87+ dwSdkAppid unsigned int/4 sdkappid
88+ dwRoomId unsigned int/4 群组号码
89+ dwExpTime unsigned int/4 过期时间 (当前时间 + 有效期(单位:秒,建议300秒))
90+ dwPrivilegeMap unsigned int/4 权限位
91+ dwAccountType unsigned int/4 第三方帐号类型
92+ */
93+ int accountLength = account .length ();
94+ int offset = 0 ;
95+ byte [] userbuf = new byte [1 +2 +accountLength +4 +4 +4 +4 +4 ];
96+
97+ //cVer
98+ userbuf [offset ++] = 0 ;
99+
100+ //wAccountLen
101+ userbuf [offset ++] = (byte )((accountLength & 0xFF00 ) >> 8 );
102+ userbuf [offset ++] = (byte )(accountLength & 0x00FF );
103+
104+ //buffAccount
105+ for (; offset < 3 + accountLength ; ++offset ) {
106+ userbuf [offset ] = (byte )account .charAt (offset - 3 );
107+ }
108+
109+ //dwSdkAppid
110+ userbuf [offset ++] = (byte )((sdkappid & 0xFF000000 ) >> 24 );
111+ userbuf [offset ++] = (byte )((sdkappid & 0x00FF0000 ) >> 16 );
112+ userbuf [offset ++] = (byte )((sdkappid & 0x0000FF00 ) >> 8 );
113+ userbuf [offset ++] = (byte )(sdkappid & 0x000000FF );
114+
115+ //dwAuthId
116+ userbuf [offset ++] = (byte )((dwAuthID & 0xFF000000 ) >> 24 );
117+ userbuf [offset ++] = (byte )((dwAuthID & 0x00FF0000 ) >> 16 );
118+ userbuf [offset ++] = (byte )((dwAuthID & 0x0000FF00 ) >> 8 );
119+ userbuf [offset ++] = (byte )(dwAuthID & 0x000000FF );
120+
121+ //dwExpTime
122+ userbuf [offset ++] = (byte )((dwExpTime & 0xFF000000 ) >> 24 );
123+ userbuf [offset ++] = (byte )((dwExpTime & 0x00FF0000 ) >> 16 );
124+ userbuf [offset ++] = (byte )((dwExpTime & 0x0000FF00 ) >> 8 );
125+ userbuf [offset ++] = (byte )(dwExpTime & 0x000000FF );
126+
127+ //dwPrivilegeMap
128+ userbuf [offset ++] = (byte )((dwPrivilegeMap & 0xFF000000 ) >> 24 );
129+ userbuf [offset ++] = (byte )((dwPrivilegeMap & 0x00FF0000 ) >> 16 );
130+ userbuf [offset ++] = (byte )((dwPrivilegeMap & 0x0000FF00 ) >> 8 );
131+ userbuf [offset ++] = (byte )(dwPrivilegeMap & 0x000000FF );
132+
133+ //dwAccountType
134+ userbuf [offset ++] = (byte )((dwAccountType & 0xFF000000 ) >> 24 );
135+ userbuf [offset ++] = (byte )((dwAccountType & 0x00FF0000 ) >> 16 );
136+ userbuf [offset ++] = (byte )((dwAccountType & 0x0000FF00 ) >> 8 );
137+ userbuf [offset ++] = (byte )(dwAccountType & 0x000000FF );
138+
139+ return userbuf ;
140+ }
80141
81142 public String genSig (String identifier , long expire ) {
82143 return genSig (identifier , expire , null );
0 commit comments