title: ValueError: malformed sha256_crypt hash (checksum must be exactly 43 chars)
body: <p>I've a question about this error. I'm relatively new to this with flask, databases and sha256_crypt so I hope someone can easily help me with this. </p>
  
  <p>I've made a login page and when I try to login with a right username, I alway get this error in my browser, when the password is right and when it's wrong.</p>
  
  <p>error:</p>
  
  <blockquote>
    <p>"builtins.ValueError
     ValueError: malformed sha256_crypt hash (checksum must be exactly 43 chars)"</p>
  </blockquote>
  
  <p>code where I think the problem should be:                                      </p>
  
  <pre><code>@app.route('/login', methods=['GET','POST']) 
  def login():
      if request.method == 'POST':
      #get form fields
      username = request.form['username']
      password_candidate = request.form['password']
  
      #create cursor 
      cur = mysql.connection.cursor()
  
      #get user by username
      result = cur.execute("SELECT * FROM users WHERE username = %s", [username])
  
      if result &gt; 0:
          #get stored hash
          data = cur.fetchone()
          password = data['password']
  
          #compare passwords 
          if sha256_crypt.verify(password_candidate, password):
              app.logger.info('PASSWORD MATCHED')
          else:
              app.logger.info('PASSWORD DOES NOT MATCH')
  
      else:
          app.logger.info('NO SUCH USER FOUND')
  
  
  
  return render_template('login.html')
  </code></pre>
  
  <p>I have already searched a lot but I cant seem to find how to fix it and make it possible to login with a username and password from the database.</p>
  
  <p>Thank you in advance</p>
  
  <p>Robbe </p>