title: Hashing a variable in python 3
body: <p>I'm using python 3 and i need to know how to use hashing in python 3 on a variable instead of a string.</p>
  
  <p>my example;
  this is the code i'm currently trying to use and it doesn't work.</p>
  
  <pre><code>foundpassencypt = hashlib.md5(b(pwd))
  print(foundpassencypt.hexdigest()) 
  </code></pre>
  
  <p>pwd is a string that was entered earlier in my program.</p>
  
  <pre><code>pwd = "Password"
  </code></pre>
  
  <p>i know if it was a string it would be layed out like this;</p>
  
  <pre><code>foundpassencypt = hashlib.md5(b"Password")
  print(foundpassencypt.hexdigest()) 
  </code></pre>
  
  <p>This is the full code (its using Python3, SQL Lite and <a href="http://appjar.info/" rel="nofollow noreferrer">Appjar</a>)("Else:" is out of place when i post the code, its correct in my code)</p>
  
  <pre><code>    else:
      usr = login.getEntry("Username")
      pwd = login.getEntry("Password") #collects entry of password &amp; username
  
      conn = sqlite3.connect("uHubDatabase.db")
      cursor = conn.cursor() #connects to database
  
      find_user=("SELECT Username FROM UserTable WHERE Username = ?") #sets the finding of the username from the database as a varaible 
      cursor.execute(find_user,[(usr)])
  
  
      founduser = str(cursor.fetchall())
      print(founduser)
      removechars = "'(),[]" #Avoids the error of special characters caused by the database outputting strings (Text)
      for char in removechars:
          founduser = founduser.replace(char,'')
  
      find_pass=("SELECT Password FROM UserTable WHERE Password = ?") #sets the finding of the password from the database as a varaible 
      cursor.execute(find_pass,[(pwd)])
  
      foundpass = str(cursor.fetchall())
      print(foundpass)
      removechars = "'(),[]" #Avoids the error of special characters caused by the database outputting strings (Text)
      for char in removechars:
          foundpass = foundpass.replace(char,'')
  
      pwdencypt = hashlib.md5(pwd) #makes the encypted password using md5 hashing
      print(pwdencypt.hexdigest()) # checks the string for comparison
  
      print(founduser) 
      print(usr) 
      print(foundpass) 
      print(pwd) 
  
      if founduser == usr and foundpass == pwdencypt: # If correct
          print("SUCESS")
          login.stop()
          home.go()
  
      else: #if incorrect
          print("FAIL")
          login.retryBox("INCORRECT LOGIN", "The Username or Password entered are incorrect. Please try again.", parent=login)
      print("User:", usr, "Pass:", pwd)
  
      conn.close() #closes connection
  </code></pre>