cookie_tool.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:docklet 作者: unias 项目源码 文件源码
def generate_cookie(name, securekey):
    #print (">> generate cookie for %s" % name)
    content = { 'name':name, 'login-time': time.asctime() }
    text = json.dumps(content)
    part1 = base64.b64encode(text.encode('ascii'))
    part2 = hashlib.md5( (text+securekey).encode('ascii') ).hexdigest()
    # part1 is binary(ascii) and part2 is str(utf-8)
    cookie = str(part1, encoding='utf-8') +"."+ part2
    #print ("cookie : %s" % cookie)
    return cookie
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号