分销商城(微商城)接口项目

fx_token_service.go 647B

1234567891011121314151617181920212223242526272829
  1. package service
  2. import (
  3. "crypto/md5"
  4. "fmt"
  5. "time"
  6. "github.com/astaxie/beego"
  7. )
  8. func CreateFxToken(orgId int64, adminId int) (string, int64) {
  9. // $_GPC['fxtoken']) && isset($_GPC['fxorgid']) && isset($_GPC['timestamp']) && isset($_GPC['fxadmin']
  10. nowTime := time.Now().Unix()
  11. fxKey := beego.AppConfig.String("fxtokenkey")
  12. stringA := fmt.Sprintf("org_id=%d&time=%d", orgId, nowTime)
  13. data := []byte(stringA)
  14. has := md5.Sum(data)
  15. md5str := fmt.Sprintf("%x", has)
  16. stringB := fmt.Sprintf("string=%s&key=%s", md5str, fxKey)
  17. data = []byte(stringB)
  18. has = md5.Sum(data)
  19. signToken := fmt.Sprintf("%x", has)
  20. return signToken, nowTime
  21. }