订单计算相关
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
766 B

3 years ago
  1. package ordercalc
  2. import (
  3. "crypto/md5"
  4. "encoding/hex"
  5. "strings"
  6. )
  7. /**
  8. * 通知订单状态时签名
  9. * 签名方式md5(order_sn-status--time---appid)
  10. * 2020/08/21
  11. *gz
  12. */
  13. func Sign(order_sn, status, time, appid string) string {
  14. return Md5Password(StringJoin(order_sn, "--", status, "--", time, "--", appid))
  15. }
  16. //密码加密
  17. func Md5Password(password string) string {
  18. h := md5.New()
  19. h.Write([]byte(password)) // 需要加密的字符串
  20. cipher2Str := h.Sum(nil)
  21. sMd5 := hex.EncodeToString(cipher2Str) // 输出加密结果
  22. return sMd5
  23. }
  24. /*
  25. * 连接多个字符串
  26. * 2019/05/05
  27. */
  28. func StringJoin(s ...string) string {
  29. var build strings.Builder
  30. if len(s) > 0 {
  31. for _, v := range s {
  32. build.WriteString(v)
  33. }
  34. }
  35. return build.String()
  36. }