def changePassword(self,NewPassword,adminId):
def Hash(NewPassword,adminId):
print("adgjadg")
salt = os.urandom(32) # A new salt for this user
key = hashlib.pbkdf2_hmac('sha256',NewPassword.encode('utf-8'),salt,100000)
NewPassword = {'salt': salt,'key': key} # stores salt and key
print(NewPassword)
storage = salt + key
print(storage)
saltFromStorage = storage[:32]
keyFromStorage = storage[32:]
storage = str(storage)
print(adminId)
updatePassword = f"UPDATE users SET password = ? WHERE username = '{adminId}'"
cur.execute(updatePassword,storage)
con.commit()
The hashing algorithm is perfectly functional but trying to store the salt and key in the database doesn't seem to work. I don't think it likes all the symbols like ' and / included in the key.
Here' an example of a key and salt put together: b'n\x8d\x9a\x8c\xb6b5.\xd4\x18^\x9c\xc9\x1e\x86\\xf6\xb0\x90\x1d\n\xa3x$C\xe2\xec\xcd+\xa694\xcf\xaa\x00<\xa2\xf2vC\x00\xba\x97I&\x96\x10\x15i\x19\xb3z\xea\xa1m\xd7\x84c\x08\xb8\x14u\xc7N'
Is it even possible to store a string the complex into a binary db file or am I doing something wrong?
File "/Users/kevinoo/Desktop/cpsc nea/NEAMainPage.py", line 209, in Hash cur.execute(updatePassword,storage) sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 189 supplied.
Gives me this error, 189 supplied??? cmon now