@@ -10,7 +10,75 @@ import (
1010 "strconv"
1111 "time"
1212)
13+ func GetUserBuf (account string , dwSdkappid uint32 ,dwAuthID uint32 ,
14+ dwExpTime uint32 ,dwPrivilegeMap uint32 ,dwAccountType uint32 ) []byte {
1315
16+ offset := 0 ;
17+ length := 1 + 2 + len (account )+ 20 ;
18+ userBuf := make ([]byte ,length );
19+
20+ userBuf [offset ]= 0 ;
21+ offset ++ ;
22+ userBuf [offset ] = (byte )((len (account ) & 0xFF00 ) >> 8 );
23+ offset ++ ;
24+ userBuf [offset ] = (byte )(len (account ) & 0x00FF );
25+ offset ++ ;
26+
27+ for ; offset < len (account ) + 3 ; offset ++ {
28+ userBuf [offset ] = account [offset - 3 ];
29+ }
30+
31+ //dwSdkAppid
32+ userBuf [offset ] = (byte )((dwSdkappid & 0xFF000000 ) >> 24 );
33+ offset ++ ;
34+ userBuf [offset ] = (byte )((dwSdkappid & 0x00FF0000 ) >> 16 );
35+ offset ++ ;
36+ userBuf [offset ] = (byte )((dwSdkappid & 0x0000FF00 ) >> 8 );
37+ offset ++ ;
38+ userBuf [offset ] = (byte )(dwSdkappid & 0x000000FF );
39+ offset ++ ;
40+
41+ //dwAuthId
42+ userBuf [offset ] = (byte )((dwAuthID & 0xFF000000 ) >> 24 );
43+ offset ++ ;
44+ userBuf [offset ] = (byte )((dwAuthID & 0x00FF0000 ) >> 16 );
45+ offset ++ ;
46+ userBuf [offset ] = (byte )((dwAuthID & 0x0000FF00 ) >> 8 );
47+ offset ++ ;
48+ userBuf [offset ] = (byte )(dwAuthID & 0x000000FF );
49+ offset ++ ;
50+
51+ //dwExpTime 不确定是直接填还是当前s数加上超时时间
52+ userBuf [offset ] = (byte )((dwExpTime & 0xFF000000 ) >> 24 );
53+ offset ++ ;
54+ userBuf [offset ] = (byte )((dwExpTime & 0x00FF0000 ) >> 16 );
55+ offset ++ ;
56+ userBuf [offset ] = (byte )((dwExpTime & 0x0000FF00 ) >> 8 );
57+ offset ++ ;
58+ userBuf [offset ] = (byte )(dwExpTime & 0x000000FF );
59+ offset ++ ;
60+
61+ //dwPrivilegeMap
62+ userBuf [offset ] = (byte )((dwPrivilegeMap & 0xFF000000 ) >> 24 );
63+ offset ++ ;
64+ userBuf [offset ] = (byte )((dwPrivilegeMap & 0x00FF0000 ) >> 16 );
65+ offset ++ ;
66+ userBuf [offset ] = (byte )((dwPrivilegeMap & 0x0000FF00 ) >> 8 );
67+ offset ++ ;
68+ userBuf [offset ] = (byte )(dwPrivilegeMap & 0x000000FF );
69+ offset ++ ;
70+
71+ //dwAccountType
72+ userBuf [offset ] = (byte )((dwAccountType & 0xFF000000 ) >> 24 );
73+ offset ++ ;
74+ userBuf [offset ] = (byte )((dwAccountType & 0x00FF0000 ) >> 16 );
75+ offset ++ ;
76+ userBuf [offset ] = (byte )((dwAccountType & 0x0000FF00 ) >> 8 );
77+ offset ++ ;
78+ userBuf [offset ] = (byte )(dwAccountType & 0x000000FF );
79+ offset ++ ;
80+ return userBuf ;
81+ }
1482func hmacsha256 (sdkappid int , key string , identifier string , currTime int64 , expire int , base64UserBuf * string ) string {
1583 var contentToBeSigned string
1684 contentToBeSigned = "TLS.identifier:" + identifier + "\n "
0 commit comments