2.0订单rpc数据结构
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.

37 lines
604 B

  1. package orderrpcv2
  2. import (
  3. "crypto/md5"
  4. "encoding/hex"
  5. "strings"
  6. )
  7. /**
  8. * 签名
  9. */
  10. func Sign(data string, salt string) string {
  11. var build strings.Builder
  12. build.WriteString(data)
  13. build.WriteString(salt)
  14. build.WriteString("oO&%$yLtesD")
  15. data_str := build.String()
  16. h := md5.New()
  17. h.Write([]byte(data_str)) // 需要加密的字符串
  18. return hex.EncodeToString(h.Sum(nil)) // 输出加密结果
  19. }
  20. /**
  21. * 验证签名
  22. */
  23. func CheckSign(sign_str, data, salt string) bool {
  24. sign := Sign(data, salt)
  25. if strings.Compare(sign_str, sign) > -1 {
  26. return true
  27. }
  28. return false
  29. }