1234567891011121314151617181920212223242526272829 |
- package service
-
- import (
- "crypto/md5"
- "fmt"
- "time"
-
- "github.com/astaxie/beego"
- )
-
- func CreateFxToken(orgId int64, adminId int) (string, int64) {
-
- // $_GPC['fxtoken']) && isset($_GPC['fxorgid']) && isset($_GPC['timestamp']) && isset($_GPC['fxadmin']
- nowTime := time.Now().Unix()
- fxKey := beego.AppConfig.String("fxtokenkey")
- stringA := fmt.Sprintf("org_id=%d&time=%d", orgId, nowTime)
-
- data := []byte(stringA)
- has := md5.Sum(data)
- md5str := fmt.Sprintf("%x", has)
- stringB := fmt.Sprintf("string=%s&key=%s", md5str, fxKey)
-
- data = []byte(stringB)
- has = md5.Sum(data)
- signToken := fmt.Sprintf("%x", has)
-
- return signToken, nowTime
- }
|