'Werkzeug.security and generate_password_hash, but encrypting several data points and using one check_password_hash for all data points

I am trying to see if I can encrypt several separate data points in a database and then also store a private key or password to decrypt all the data. Please let me know if this can be done with werkzeug.security's generate_password_hash and check_password_hash or another library. I have a feeling it cannot be done with the aforementioned methods in werkzeug.

Database Example:

class Data(db.Model):
   id = db.Column(db.Integer, primary_key=True)
   name = db.Column(db.String(100))
   favorite_movie = db.Column(db.String(100))
   private_key = db.Column(db.String(100))

class AddDataForm(FlaskForm):
   name = StringField('Name', validators=[InputRequired(), Length(min=1, max=100)])
   favorite_movie = StringField('Favorite Movie', validators=[InputRequired(), Length(min=1,max=100)])
   private_key = StringField('Private Key', validators=[InputRequired(), Length(min=1, max=100)])

Flask/Python Handle:

@app.route('/home', methods=['POST', 'GET'])
def take_in_data_form_then_encrypt():
   form = AddDataForm()
   if form.validate_on_submit():
      hashed_name = generate_password_hash(form.name.data, method='sha256', salt_length=16)
      hashed_favorite_movie = generate_password_hash(form.favorite_movie.data, method='sha256', salt_length=16)
      hashed_private_key = generate_password_hash(form.private_key.data, method='sha256', salt_length=16)
      new_name = Data(name=hashed_name, favorite_movie=hashed_favorite_movie, private_key=hashed_private_key)
      db.session.add(new_name)
      db.session.commit()
      return redirect(url_for('data_added'))
   return render_template('add_data.html', form=form)

And then I would have a page similar to a login page, and the page asks for an inputted private_key and does check_password_hash(inputted_private_key, hashed_private_key) and the name and favorite_movie data could be verified without having to re-enter the data and check the hash for those pieces of information. Thank you.

...Trying to use it for sensitive information say credit card numbers if that helps visualize. Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source