package agiso

import (
	"context"
	"fmt"
	"kami/utility/config"

	"github.com/gogf/gf/v2/crypto/gmd5"
	"github.com/gogf/gf/v2/text/gstr"
	"github.com/gogf/gf/v2/util/gconv"
)

// GenerateCallbackSign 验证回调签名
func GenerateCallbackSign(ctx context.Context, jsonStr string, timestamp int) (newSign string) {
	newSign = ""
	cfg, err := config.NewConfig(ctx).GetAgiso()
	if err != nil {
		return
	}
	return gstr.ToUpper(gmd5.MustEncrypt(fmt.Sprintf("%sjson%stimestamp%s%s", cfg.AppSecret, jsonStr, gconv.String(timestamp), cfg.AppSecret)))
}
