from app import databases
from passlib.hash import pbkdf2_sha256

from itsdangerous import (TimedJSONWebSignatureSerializer as Serializer,
                          BadSignature, SignatureExpired)


class Items(databases.Model):
    __tablename__ = 'BucketListItems'

    id = databases.Column(databases.Integer, primary_key=True, autoincrement=True)
    name = databases.Column(databases.String(250))
    datecreated = databases.Column(databases.DateTime, default=databases.func.current_timestamp())
    date_modified = databases.Column(databases.DateTime, default=databases.func.current_timestamp())
    bucketlist_id = databases.Column(databases.Integer(), databases.ForeignKey('Bucketlist.id'))

    def __init__(self, name, id):
        self.name = name
        self.bucketlist_id = id

    def save(self):
        databases.session.add(self)
        databases.session.commit()

    def __repr__(self):
        return '<Items {}'.format(self.name)


class BucketList(databases.Model):
    __tablename__ = 'Bucketlist'
    id = databases.Column(databases.Integer, primary_key=True, autoincrement=True)
    user = databases.Column(databases.Integer(), databases.ForeignKey('UserInfo.id'))
    name = databases.Column(databases.String(255))
    items = databases.relationship('Items', backref="Bucketlist")
    date_created = databases.Column(databases.DateTime, default=databases.func.current_timestamp())
    date_modified = databases.Column(databases.DateTime, default=databases.func.current_timestamp())
    created_by = databases.Column(databases.Integer)

    def __init__(self, name):
        self.name = name

    def save(self):
        databases.session.add(self)
        databases.session.commit()


class Users(databases.Model):
    __tablename__ = 'UserInfo'
    id = databases.Column(databases.Integer, primary_key=True, autoincrement=True)
    Bucket = databases.relationship('BucketList', backref='UserInfo')
    username = databases.Column(databases.String(250))
    password_hash = databases.Column(databases.String(300))

    def save(self):
        databases.session.add(self)
        databases.session.commit()

    def hash_password(self, password):
        self.password_hash = pbkdf2_sha256.hash(password)

    def verify_password(self, password):
        return pbkdf2_sha256.verify(password, self.password_hash)

    def generate_auth_token(self, expiration=600):
        s = Serializer(app_config['SECRET_KEY'], expires_in=expiration)
        return s.dumps({'id': self.id})

    @staticmethod
    def verify_auth_token(token):
        s = Serializer(app_config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except SignatureExpired:
            return None
        except BadSignature:
            return None
        user = Users.query.get(data['id'])
        return user

@@ -36,20 +36,20 @@
 lib.
-hash
+apps
  import 
 pbkd
@@ -48,153 +48,41 @@
 ort 
-pbkdf2_sha256%0A%0Afrom itsdangerous import (TimedJSONWebSignatureSerializer as Serializer,%0A                          BadSignature, SignatureExpired)
+custom_app_context as pwd_context
 %0A%0A%0Ac
@@ -2089,25 +2089,26 @@
  = p
-bkdf2_sha256.hash
+wd_context.encrypt
 (pas
@@ -2176,20 +2176,18 @@
 rn p
-bkdf2_sha256
+wd_context
 .ver
@@ -2224,490 +2224,4 @@
 sh)%0A
-%0A    def generate_auth_token(self, expiration=600):%0A        s = Serializer(app_config%5B'SECRET_KEY'%5D, expires_in=expiration)%0A        return s.dumps(%7B'id': self.id%7D)%0A%0A    @staticmethod%0A    def verify_auth_token(token):%0A        s = Serializer(app_config%5B'SECRET_KEY'%5D)%0A        try:%0A            data = s.loads(token)%0A        except SignatureExpired:%0A            return None%0A        except BadSignature:%0A            return None%0A        user = Users.query.get(data%5B'id'%5D)%0A        return user%0A

Use passlib pwd_context to encrypt passwords