from hashlib import *


class Cookie:
    def __init__(self, user_name: str, login_time: str, login_state: str, cookie=None):
        self.user_name = user_name
        self.login_time = login_time
        self.login_state = login_state
        self.cookie = cookie

    def generate_cookie(self):
        s1 = sha1()
        s1.update(str(self.user_name+self.login_time+self.login_state).encode())
        self.cookie = s1.hexdigest()
        return self.cookie

    def __str__(self):
        return self.cookie
