创建MemberService
MemberService服务管理类包含了获取token、生成salt加密字符串、获取openId
# -*- coding: utf-8 -*- # hashlib加密、base64编码 import hashlib, base64 import random, string,json,requests from application import app # 用户服务类 class MemberService(): def __init__(self): pass # 使用用户信息进行MD5加密 @staticmethod def geneAuthCode(member_info = None): m = hashlib.md5() # 用户uid、用户登录名称、用户密码、用户salt(用于加密的密钥) str = "%s-%s-%s" % (member_info.id,member_info.salt,member_info.status) m.update(str.encode("utf-8")) return m.hexdigest() # 生成salt @staticmethod def geneSalt(length=16): keylist = [random.choice((string.ascii_letters + string.digits)) for i in range(length)] return "".join(keylist) @staticmethod def getWeChatOpenId(code): # url=