Verification Example
License 校验示例
服务端签名密钥不下发前端。客户端只拿到授权码和公开校验逻辑示例。
func VerifyLicense(licenseKey string, secret string) bool {
parts := strings.Split(licenseKey, ".")
if len(parts) != 2 {
return false
}
payload, signature := parts[0], parts[1]
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(payload))
expected := hex.EncodeToString(mac.Sum(nil))
return hmac.Equal([]byte(expected), []byte(signature))
}