| @@ -13,7 +13,15 @@ func md5str(s string) string { | |||
| return fmt.Sprintf("%x", h.Sum(nil)) | |||
| } | |||
| func md5LeanworkForm(form url.Values) string { | |||
| func MD5LeanworkFormP2P(form url.Values) string { | |||
| return md5LeanworkForm(form, Config.LeanWork.MD5P2P) | |||
| } | |||
| func MD5LeanworkFormFAT(form url.Values) string { | |||
| return md5LeanworkForm(form, Config.LeanWork.MD5FAT) | |||
| } | |||
| func md5LeanworkForm(form url.Values, key string) string { | |||
| s := "" | |||
| if _, ok := form["pickupUrl"]; ok { | |||
| s += form["pickupUrl"][0] | |||
| @@ -23,14 +31,14 @@ func md5LeanworkForm(form url.Values) string { | |||
| s += form["orderAmount"][0] | |||
| s += form["orderCurrency"][0] | |||
| s += form["customerId"][0] | |||
| s += Config.LeanWork.MD5Key | |||
| s += key | |||
| } | |||
| //fmt.Println("leanwork form: " + s) | |||
| return md5str(s) | |||
| } | |||
| func isLeanworkFormValid(form url.Values) bool { | |||
| r := md5LeanworkForm(form) | |||
| func isLeanworkFormValid(form url.Values, md5key string) bool { | |||
| r := md5LeanworkForm(form, md5key) | |||
| sign := form["sign"][0] | |||
| return r == sign | |||
| } | |||