This repository has been archived on 2024-09-30. You can view files and clone it, but cannot push or open issues/pull-requests.
SmartRollCall/models/User.py

16 lines
540 B
Python

import bcrypt
class User:
def __init__(self, name, number, password, status):
self.name = name # 用户昵称
self.number = number # 手机号
self.password = self.hash_password(password) # 哈希密码
self.status = status # 状态(是否可用)
def hash_password(self, password):
return bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
def __str__(self):
return f"User({self.name}, {self.number}, {'Active' if self.status else 'Inactive'})"