19 lines
366 B
Python
19 lines
366 B
Python
from database import execute
|
|
import bcrypt
|
|
|
|
def create_user(username, password):
|
|
|
|
password_hash = bcrypt.hashpw(
|
|
password.encode(),
|
|
bcrypt.gensalt()
|
|
).decode()
|
|
|
|
user_id = execute(
|
|
"""
|
|
INSERT INTO users (username, password_hash)
|
|
VALUES (?, ?)
|
|
""",
|
|
(username, password_hash)
|
|
)
|
|
|
|
return user_id |