Exemplo n.º 1
0
func initTemplate(c *gof.Config) *gof.Template {
	spam := crypto.Md5([]byte(strconv.Itoa(int(time.Now().Unix()))))[8:14]
	return &gof.Template{
		Init: func(m *gof.TemplateDataMap) {
			v := *m
			v["static_serve"] = c.GetString(variable.StaticServer)
			v["img_serve"] = c.GetString(variable.ImageServer)
			v["domain"] = c.GetString(variable.ServerDomain)
			v["version"] = c.GetString(variable.Version)
			v["spam"] = spam
		},
	}
}
Exemplo n.º 2
0
//登录验证
func (this *Member) Login(m *jsv.Args, r *dto.MemberLoginResult) error {
	usr, pwd := (*m)["usr"].(string), (*m)["pwd"].(string)
	partnerId, _ := strconv.Atoi((*m)["partner_id"].(string))
	b, e, err := dps.MemberService.Login(partnerId, usr, pwd)
	r.Result = b
	if b {
		md5 := strings.ToLower(crypto.Md5([]byte(time.Now().String())))
		rds := Redis().Get()
		rds.Do("SETEX", fmt.Sprintf("dps:session:m%d", e.Id), 3600*3, md5)

		if jsv.Context.Debug() {
			jsv.Printf("[Member][Login]%d -- %s", e.Id, md5)
		}
		rds.Close()
		e.DynamicToken = md5
		r.Member = e
	}
	if err != nil {
		r.Message = err.Error()
	}
	return nil
}
Exemplo n.º 3
0
//创建密钥(16位)
func NewSecret(hex int) string {
	str := fmt.Sprintf("%d$%d", hex, time.Now().Add(time.Hour*24*365).Unix())
	return crypto.Md5([]byte(str))[8:24]
}
Exemplo n.º 4
0
// 创建邀请码(6位)
func GenerateInvitationCode() string {
	var seed string = fmt.Sprintf("%d%s", time.Now().Unix(), util.RandString(6))
	var md5 = crypto.Md5([]byte(seed))
	return md5[8:14]
}
Exemplo n.º 5
0
// 密码Md5加密
func Md5Pwd(pwd, offset string) string {
	return crypto.Md5([]byte(strings.Join([]string{offset, "*****@*****.**", pwd}, "")))
}
Exemplo n.º 6
0
// 密码Md5加密
func Md5Pwd(pwd, str string) string {
	return crypto.Md5([]byte(strings.Join([]string{str, Sha1OffSet, pwd}, "")))
}
Exemplo n.º 7
0
// 生成16位唯一的md5购物车码
func GenerateCartKey(unix int64, nano int) string {
	str := fmt.Sprintf("%d-%d*%d", unix, nano, unix%int64(nano))
	result := crypto.Md5([]byte(str))
	return result[8:24]
}