Skip to content

Commit

Permalink
修改证判断bug
Browse files Browse the repository at this point in the history
  • Loading branch information
microrain authored and microrain committed Aug 31, 2023
1 parent 2b3d876 commit 2c90312
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
1 change: 0 additions & 1 deletion app.lic

This file was deleted.

4 changes: 2 additions & 2 deletions cmd/CreateLic/aaa.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"AppName":"SagooAPP",
"AppName":"SagooIOT",
"AppCompany":"Shenyang Sagoo Education Technology Co., Ltd",
"EncryptSalt":"afsrewfs2342423",
"AppUUID":"556677888",
"AppUUID":"55667788811111111111111111",
"ObjUUID":"BF1E62B3-8FD0-5AC4-8E9E-C3672116EB33",
"AuthorizedName":"XXXXX公司",
"LimitedTime":"20240101"
Expand Down
2 changes: 1 addition & 1 deletion examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func main() {

//======================进行license控制作===========================================
lic, err := LicenseManager.ValidAppLic("app.lic", "558FEC81051A2020")
lic, err := LicenseManager.ValidAppLic("app.lic", "0123456789012345")
if lic {
if err != nil {
fmt.Println(err.Error())
Expand Down
4 changes: 2 additions & 2 deletions lic.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func ValidAppLic(appInfoFile, key string) (res bool, err error) {
//进行解密
tmpText = utils.AesDecrypt(tmpText, key)
conf := AppLicenseInfo{}
if err := json.Unmarshal([]byte(tmpText), &conf); err != nil {
if err := json.Unmarshal([]byte(tmpText), &conf); err == nil {
//获取本机的ID
id, err := machineid.ID()
if err != nil {
Expand All @@ -99,5 +99,5 @@ func ValidAppLic(appInfoFile, key string) (res bool, err error) {
}

}
return
return true, nil
}
28 changes: 11 additions & 17 deletions lic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,21 @@ func TestValidAppLic(t *testing.T) {

licFilePath := "app.lic"
lic, err := ValidAppLic(licFilePath, "1234567890123456")
if err != nil {
t.Log(err.Error())
}
if lic {
fmt.Println("License is valid!")
} else {
fmt.Println("License is invalid!")
if err != nil {
fmt.Println(err.Error())
return
}
// 授权成功
t.Log("授权有效")
return
}
t.Log("TestValidAppLic OK!")
t.Log("授权无效,请联系管理员!")
}

func TestEncryptLic(t *testing.T) {
lic, err := ValidAppLic("app.lic", "1234567890123456")
if err != nil {
t.Log(err.Error())
}
if lic {
fmt.Println("License is valid!")
} else {
fmt.Println("License is invalid!")
}
t.Log(lic)

licFilePath := "aaa.json"
EncryptLic(licFilePath, "1234567890123456")
t.Log("success")
}

0 comments on commit 2c90312

Please sign in to comment.