Skip to content

Commit 448d554

Browse files
committed
添加统一接口
1 parent 2d84524 commit 448d554

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tls-sig-api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ func GenerateUsersig(privateKey string, appid int, identifier string) (string, e
154154
return GenerateUsersigWithExpire(privateKey, appid, identifier, 60*60*24*180)
155155
}
156156

157+
func genSig(sdkappid int, identifier string, priKey string) (string, error) {
158+
return GenerateUsersigWithExpire(priKey, sdkappid, identifier, 60*60*24*180)
159+
}
160+
157161
func GenerateUsersigWithUserbuf(privateKey string, appid int, identifier string, expire int64, userbuf []byte) (string, error) {
158162
obj := map[string]string{
159163
"TLS.account_type": "0",

tls-sig-api_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ func TestGenAndVerify(t *testing.T) {
4242
}
4343
}
4444

45+
func TestGenSigAndVerfiy(t *testing. T) {
46+
userSig, err := genSig(14000, "xiaojun", privateKey)
47+
if err != nil {
48+
t.Fatal(err)
49+
}
50+
err = VerifyUsersig(publicKey, userSig, 14000, "xiaojun")
51+
if err != nil {
52+
t.Fatal(err)
53+
}
54+
}
55+
4556
func TestGenAndVerifyExpire(t *testing.T) {
4657
userSig, err := GenerateUsersigWithExpire(privateKey, 1, "1", 0)
4758
if err != nil {

0 commit comments

Comments
 (0)