Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Created March 16, 2020 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuongld2/7dfc6cfb38e374c86a86bb934480bb57 to your computer and use it in GitHub Desktop.
Save cuongld2/7dfc6cfb38e374c86a86bb934480bb57 to your computer and use it in GitHub Desktop.
hash_password_with_bcrypt
def create_user(db: Session, user: schemas.UserCreate):
hashed_password = bcrypt.hashpw(user.password.encode('utf-8'), bcrypt.gensalt())
db_user = models.UserInfo(username=user.username, password=hashed_password, fullname=user.fullname)
db.add(db_user)
db.commit()
db.refresh(db_user)
return db_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment