【发布时间】:2015-11-18 14:43:53
【问题描述】:
我不明白我应该如何使用 scrypt 存储散列密码。
示例如下:
import pyscrypt
hashed = pyscrypt.hash(password = b"password",
salt = b"seasalt",
N = 1024,
r = 1,
p = 1,
dkLen = 16)
print(hashed.hex()) #70ac953b777e24c4f41c4657eb9f03c2
hashed = pyscrypt.hash(password = b"password",
salt = b"seasalt",
N = 1024,
r = 2,
p = 1,
dkLen = 16)
print(hashed.hex()) #b00b951cd50675806c55d903dba9cbca
hashed = pyscrypt.hash(password = b"password",
salt = b"seasalt",
N = 1024,
r = 1,
p = 2,
dkLen = 16)
print(hashed.hex()) #7c3fa22552c8a9071da0e8c80a0a2767
在上面的示例中,我们可以看到哈希值根据参数N, r, p 的值而改变。
这是否意味着我也应该在数据库中保存 N, r, p 值?
当市场上出现更强大的硬件时,我应该怎么做?例如,要求用户更改密码以便应用新的哈希函数或其他什么?
【问题讨论】:
-
你为什么使用这个库而不是
passlib,它可以很容易地存储和理解参数化和加盐的哈希值。 -
@Antti 只是猜测,但是 passlib 不支持 scrypt...!?
标签: python python-3.x hash password-protection scrypt