在Python中使用Bcrypt哈希密码时出错
在Python中使用在Python中使用Bcrypt哈希密码时出错,python,hash,bcrypt,Python,Hash,Bcrypt,在Python中使用Bcrypt对文本密码进行哈希运算时出错。我在下面提供错误信息 Traceback (most recent call last): File "hash.py", line 3, in <module> hashed = hashpw(plaintext_password, gensalt(log_rounds=13)) TypeError: gensalt() got an unexpected keyword argument 'log_roun
Bcrypt
对文本密码进行哈希运算时出错。我在下面提供错误信息
Traceback (most recent call last):
File "hash.py", line 3, in <module>
hashed = hashpw(plaintext_password, gensalt(log_rounds=13))
TypeError: gensalt() got an unexpected keyword argument 'log_rounds'
这里我需要散列我的密码。您的错误来自
日志轮次
,您只需使用该号码即可。以下是一个例子:
hashed = hashpw(plaintext_password, gensalt(13))
来自官方文件:
import bcrypt
password = b"super secret password"
# Hash a password for the first time, with a certain number of rounds
hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
# Check that a unhashed password matches one that has previously been
# hashed
if bcrypt.hashpw(password, hashed) == hashed:
print("It Matches!")
else:
print("It Does not Match :(")
可调工作系数
bcrypt的特点之一是可调对数功因数。要调整功系数,只需将所需的轮数传递给bcrypt.gensalt(轮数=12),默认为12:
工作演示:
import bcrypt
password = b"super secret password"
# Hash a password for the first time, with a certain number of rounds
hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
# Check that a unhashed password matches one that has previously been
# hashed
if bcrypt.hashpw(password, hashed) == hashed:
print("It Matches!")
else:
print("It Does not Match :(")
是指向文档的链接,其中指定了如何使用该文档
希望这有帮助 您的错误来自
log\u rounds
,您只需使用数字即可。以下是一个例子:
hashed = hashpw(plaintext_password, gensalt(13))
来自官方文件:
import bcrypt
password = b"super secret password"
# Hash a password for the first time, with a certain number of rounds
hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
# Check that a unhashed password matches one that has previously been
# hashed
if bcrypt.hashpw(password, hashed) == hashed:
print("It Matches!")
else:
print("It Does not Match :(")
可调工作系数
bcrypt的特点之一是可调对数功因数。要调整功系数,只需将所需的轮数传递给bcrypt.gensalt(轮数=12),默认为12:
工作演示:
import bcrypt
password = b"super secret password"
# Hash a password for the first time, with a certain number of rounds
hashed = bcrypt.hashpw(password, bcrypt.gensalt(14))
# Check that a unhashed password matches one that has previously been
# hashed
if bcrypt.hashpw(password, hashed) == hashed:
print("It Matches!")
else:
print("It Does not Match :(")
是指向文档的链接,其中指定了如何使用该文档
希望这有帮助 我想用
gensalt(13)
或gensalt(轮数=13)
代替gensalt(轮数=13)
我想用gensalt(13)
或gensalt(轮数=13)
代替gensalt(轮数=13)
看起来很像gensalt()
是否不将对数轮数作为参数?您是否查看了文档以了解要传递的确切内容?看起来像gensalt()
不将日志轮次作为参数?你看过这些文件了吗,看看到底要通过什么?