diff --git a/blog/models.py b/blog/models.py
index 18840c0d5a2983b21466644bac2b73553292a3de..d9dfabb2e9eab070fa4377692ce0ffaaff8e71ae 100644
--- a/blog/models.py
+++ b/blog/models.py
@@ -23,9 +23,7 @@ class User(UserMixin,db.Model):
   email=db.Column(db.String(256), unique=True)
   
   def set_password(self,password):
-    salt = bcrypt.gensalt()
-    hashed_password = bcrypt.hashpw(password.encode(), salt)
-    self.password = hashed_password.decode()
+    self.password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
 
   def check_password(self,password):
     return bcrypt.checkpw(password.encode(), self.password.encode)