Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用python在SQLITE3数据库中存储MD5哈希_Python_Hash_Sqlite - Fatal编程技术网

用python在SQLITE3数据库中存储MD5哈希

用python在SQLITE3数据库中存储MD5哈希,python,hash,sqlite,Python,Hash,Sqlite,目前,我的数据库将“密码”存储为文本,但这表示它无法按如下所示工作(密码也转换为MD5哈希): 密码“函数”: user_in = input("Please enter a password next to this text: \n") Password = hashlib.md5() Password.update(user_in.encode("utf-8")) 错误消息: sqlite3.InterfaceError: Error binding parameter 1 - prob

目前,我的数据库将“密码”存储为文本,但这表示它无法按如下所示工作(密码也转换为MD5哈希):

密码“函数”:

user_in = input("Please enter a password next to this text: \n")
Password = hashlib.md5()
Password.update(user_in.encode("utf-8"))
错误消息:

sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type.
我想知道的是如何将散列存储在SQLITE3中的数据库中

编辑:

编辑2:

user_in = input("Please enter a password next to this text: \n")
Password = hashlib.md5()
Password.update(user_in.encode("utf-8"))
Password.hexdigest()

确保cursor.execute函数的参数实际上是字符串,您将是金色的!:)


这是通过在参数传递过程中强制转换它们来实现的

运行python函数时,还是在实际将其提交给SQLServer时,您会遇到错误?@Polymer Hi。在输入用户名和密码后,我收到了错误,因此,当它被提交到SQL server时,您可以添加用于将其提交到服务器的代码吗?同样在您的服务器上,您的密码设置为什么类型?@它设置为文本。我将添加上面的代码。您是否使用password.hexdigest()作为密码变量?嘿,我知道这有点不相关,但我想问一个问题。如果我想添加登录功能,我如何检查用户名和密码是否相关?我知道我必须将用户的猜测更改为MD5,以与数据库中的猜测一致,但我如何查看以确保它确实是该用户的密码。我如何查看用户名是否在数据库中,然后查看密码是否正确。如果Accounts.db中的username(显然语法不正确),则需要使用提供的用户名,转到数据库并获取哈希密码。然后,散列他们使用相同md5输入的密码,并将其与数据库中的密码进行比较。如果两个哈希值相同,则将它们输入。如果没有,他们输入的密码就错了。如果您仍然对此感到困惑,请查看ComputerPhille提供的这段视频,很棒的视频和频道,只是为了澄清一点,MD5哈希是“唯一的”。它只能由一组字节生成,因此在这种情况下可以使用它
user_in = input("Please enter a password next to this text: \n")
Password = hashlib.md5()
Password.update(user_in.encode("utf-8"))
Password.hexdigest()
cursor.execute(sql, (str(Username), str(Password)))