package wechatpay import ( "crypto/md5" "encoding/hex" "strings" "testing" ) func TestSignMD5(t *testing.T) { got := SignMD5(map[string]string{"appid": "wx123", "mch_id": "foo", "sign": "x"}, "k") sum := md5.Sum([]byte("appid=wx123&mch_id=foo&key=k")) want := strings.ToUpper(hex.EncodeToString(sum[:])) if got != want { t.Fatalf("got %s want %s", got, want) } }