md5加密

作者: Jlan | 来源:发表于2018-12-25 19:03 被阅读12次
    def verify_user(user_id, session_id, timestamp, token):
        if abs(int(time.time())-int(timestamp)) > 60:
            return False
        m1 = hashlib.md5()
        m1.update(str(user_id).encode('utf8'))
        hashcode1 = m1.hexdigest()[8:-8]
    
        m2 = hashlib.md5()
        m2.update(str(session_id).encode('utf8'))
        hashcode2 = m2.hexdigest()[8:-8]
    
        m3 = hashlib.md5()
        m3.update(str(timestamp).encode('utf8'))
        hashcode3 = m3.hexdigest()[8:-8]
    
        hashcode = hashcode1[:8] + hashcode2[8:16] + hashcode3[-8:]
    
        if hashcode == token:
            return True
        else:
            return False
    

    相关文章

      网友评论

          本文标题:md5加密

          本文链接:https://www.haomeiwen.com/subject/lnhqlqtx.html