title: Comparing same string where one is from Flask and one from a sqlite3 database
body: <p>In a login authentication module for a webapp, I'm trying to compare two values; a user entered password, and a password hash that is stored in a sqlite3 database (the hash just being the string 'password' for now).
  The code is as follows:</p>
  
  <pre><code>@app.route("/login", methods=["GET", "POST"])
  def login():
      if request.method == "POST":
          if request.form['login'] == 'Login':
              username = request.form['username']
              user_password = request.form['password']
              #print query_db("SELECT * FROM Users WHERE Username=?", username, one=True)[0]
              try:
                  user = User(query_db("SELECT * FROM Users WHERE Username=?", username, one=True)[0])
                  print user.hash
  
              except IndexError:
                  return "INVALID USERNAME!"
              hash = User.hash
              print hash
              #print whatisthis(hash)
              print user_password
              #print whatisthis(user_password)
              if user_password == hash:
                  print "wooo!"
                  #login_user(user)
                  #flash("Logged in successfully.")
                  return "LOGIN SUCCESS!"
                  #return redirect(request.args.get("next") or url_for("index"))
              else:
                  return "INVALID PASSWORD!"
      return render_template("login.html")
  </code></pre>
  
  <p><code>User</code> is a class that gets its attributes (like .hash) from the database after accessing the database through the ID. The print statements are simply for debugging, and they do show correctly the two strings (<code>hash</code> or <code>User.hash</code>, and <code>user_password</code>) to be identical when printing them to the terminal. However, they do not evaluate True in the if <code>user_password == hash</code> statement for some reason, always defaulting to the else case. Additionally, if I try to perform <code>.encode('base64')</code> on both strings, <code>user_password</code> properly changes to base64, however hash or <code>User.hash</code> stays the same even after the .encode!</p>
  
  <p>Thanks a lot for your help with this odd problem!</p>