wechat_client_test.go 739 B

12345678910111213141516171819202122232425262728293031323334
  1. package gopay
  2. import (
  3. "crypto/md5"
  4. "encoding/hex"
  5. "encoding/xml"
  6. "fmt"
  7. "strings"
  8. "testing"
  9. )
  10. func TestMd5(t *testing.T) {
  11. st := "appid=wxdaa2ab9ef87b5497&nonceStr=9k20rM66parD2U49&package=prepay_id=wx29164301554772fbc70d1d793335446010&signType=MD5&timeStamp=1548751382&key=GFDS8j98rewnmgl45wHTt980jg543wmg"
  12. hash := md5.New()
  13. hash.Write([]byte(st))
  14. sum := hash.Sum(nil)
  15. upper := strings.ToUpper(hex.EncodeToString(sum))
  16. fmt.Println(" ssad ", upper)
  17. }
  18. func TestBodyMap_MarshalXML(t *testing.T) {
  19. maps := make(BodyMap)
  20. maps.Set("name", "jerry")
  21. maps.Set("age", 28)
  22. maps.Set("phone", "13212345678")
  23. bytes, err := xml.Marshal(&maps)
  24. if err != nil {
  25. fmt.Println("err:", err)
  26. }
  27. fmt.Println("ssss:", string(bytes))
  28. }