@@ -171,7 +171,58 @@ static int json2sig(const rapidjson::Document &json, std::string &sig, std::stri
171171 }
172172 return 0 ;
173173}
174+ TLS_API std::string getUserBuf (const std::string & account, uint32_t dwSdkappid,uint32_t dwAuthID,
175+ uint32_t dwExpTime,uint32_t dwPrivilegeMap,uint32_t dwAccountType)
176+ {
177+ int length = 1 +2 +account.length ()+20 ;
178+ int offset = 0 ;
179+ char userBuf[length];
180+ memset (userBuf,0 ,sizeof (userBuf));
181+
182+ userBuf[offset++]= 0 ;
183+
184+ userBuf[offset++] = ((account.length () & 0xFF00 ) >> 8 );
185+ userBuf[offset++] = (account.length () & 0x00FF );
186+
187+ for (;offset < account.length () + 3 ; ++offset)
188+ {
189+ userBuf[offset] = account[offset-3 ];
190+ }
174191
192+ // dwSdkAppid
193+ userBuf[offset++] = ((dwSdkappid & 0xFF000000 ) >> 24 );
194+ userBuf[offset++] = ((dwSdkappid & 0x00FF0000 ) >> 16 );
195+ userBuf[offset++] = ((dwSdkappid & 0x0000FF00 ) >> 8 );
196+ userBuf[offset++] = (dwSdkappid & 0x000000FF );
197+
198+ // dwAuthId
199+ userBuf[offset++] = ((dwAuthID & 0xFF000000 ) >> 24 );
200+ userBuf[offset++] = ((dwAuthID & 0x00FF0000 ) >> 16 );
201+ userBuf[offset++] = ((dwAuthID & 0x0000FF00 ) >> 8 );
202+ userBuf[offset++] = (dwAuthID & 0x000000FF );
203+
204+ // dwExpTime 涓嶇‘瀹氭槸鐩存帴濉繕鏄綋鍓峴鏁板姞涓婅秴鏃舵椂闂�
205+ // time_t now = time(0);
206+ // uint32_t expiredTime = now + dwExpTime;
207+ userBuf[offset++] = ((dwExpTime & 0xFF000000 ) >> 24 );
208+ userBuf[offset++] = ((dwExpTime & 0x00FF0000 ) >> 16 );
209+ userBuf[offset++] = ((dwExpTime & 0x0000FF00 ) >> 8 );
210+ userBuf[offset++] = (dwExpTime & 0x000000FF );
211+
212+ // dwPrivilegeMap
213+ userBuf[offset++] = ((dwPrivilegeMap & 0xFF000000 ) >> 24 );
214+ userBuf[offset++] = ((dwPrivilegeMap & 0x00FF0000 ) >> 16 );
215+ userBuf[offset++] = ((dwPrivilegeMap & 0x0000FF00 ) >> 8 );
216+ userBuf[offset++] = (dwPrivilegeMap & 0x000000FF );
217+
218+ // dwAccountType
219+ userBuf[offset++] = ((dwAccountType & 0xFF000000 ) >> 24 );
220+ userBuf[offset++] = ((dwAccountType & 0x00FF0000 ) >> 16 );
221+ userBuf[offset++] = ((dwAccountType & 0x0000FF00 ) >> 8 );
222+ userBuf[offset++] = (dwAccountType & 0x000000FF );
223+ return std::string (userBuf,length);
224+
225+ }
175226// 生成签名
176227TLS_API int gen_sig (uint32_t sdkappid, const std::string& identifier,
177228 const std::string& key, int expire,
0 commit comments