应用程序引擎上的bcrypt哈希密码运行非常慢(使用pybcrypt lib)?

2024-06-02 08:19:28 发布

您现在位置:Python中文网/ 问答频道 /正文

在appengine上使用bcrypt似乎在散列密码时运行得非常慢,我读到建议的(至少从2017年起)是10轮或更多轮,应该基于处理加密/解密所需的时间,而不是设定的轮数。尽管如此,当我们尝试从10开始设置不同的log_round值时,这需要很长时间,以至于如果请求需要超过60秒,我们就会碰到在GAE上出现的DeadlineExceededError!我们使用的是默认的F1实例类,因为我们没有将它设置为附录yaml. 你知道吗

我们在F2和F4实例上进行了测试,它们确实更快,但从用户体验的角度来看,它们通常仍然很慢。我想在F2实例上花了5秒才完成7个log\U回合!这个图书馆有已知的问题吗?passlib是更好的选择吗?或者这种行为正常吗?我们想我们可能遗漏了什么,但不确定是什么!你知道吗

from pybcrypt import bcrypt

# What we use for hashing
user_pass = "secret_password"
password = bcrypt.hashpw(user_pass, bcrypt.gensalt(log_rounds = 10))

# What we use to verify correct password
if bcrypt.hashpw(password_attempt, user.hashed_password) == user.hashed_password:
   #User login success
   print "Logged in!"
else:
   #User login failed
   print "Wrong credentials!"

我浏览过的一些帖子:

1)https://security.stackexchange.com/questions/17207/recommended-of-rounds-for-bcrypt

2)https://security.stackexchange.com/questions/3959/recommended-of-iterations-when-using-pkbdf2-sha256/3993#3993

3)What are Salt Rounds and how are Salts stored in Bcrypt?

4)yii CPasswordHelper: hashPassword and verifyPassword


Tags: 实例logforusepasspasswordwhatf2