package md5Util

import (
	"crypto/md5"
	"encoding/hex"
	"fmt"
)

// GenSign 生成签名
func GenSign(appId int, appSecret string, timestamp int64, jsonStr []byte) string {
	bodyMd5 := genMd5(string(jsonStr))
	return genMd5(fmt.Sprintf("%v,%v,%v,%v", appId, bodyMd5, timestamp, appSecret))
}

func genMd5(str string) string {
	h := md5.New()
	h.Write([]byte(str))
	return hex.EncodeToString(h.Sum(nil))
}
