小程序可在 Go 上完成微信手机号登录、测评、预约和下单,不再反代 Java。 Co-authored-by: Cursor <cursoragent@cursor.com>
18 lines
376 B
Go
18 lines
376 B
Go
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)
|
|
}
|
|
}
|