def generate_key(file_path): lastaccss = str(int(time.time())).encode() freq = b"10" key = bytes([random.randrange(0, 256) for _ in range(32)]) token = Encryption.encrypt(get_serial_number().encode(), lastaccss + freq + key) file = open(file_path, 'wb') file.write(token)
def update_token(file_path, token): lastaccess = int(token[:10]) freq = int(token[10:12]) lastaccess, freq = modify_threshold(lastaccess, freq) key = token[12:] token = Encryption.encrypt( get_serial_number().encode(), str(lastaccess).encode() + str(freq).encode() + key) file = open(file_path, 'wb') file.write(token)