From 621537292884bd768c54ae2f2b27a70eb4de2d36 Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 17 Mar 2020 02:18:19 +1100 Subject: [PATCH] md5 for leanwork form P2P and FAT --- checksum.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/checksum.go b/checksum.go index cd3f7a2..6948c9c 100644 --- a/checksum.go +++ b/checksum.go @@ -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 }