hashlib.scrypt的建议/最小参数是什么?

2024-05-16 00:19:52 发布

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

{a1}的文档有点短:

hashlib.scrypt(password, *, salt, n, r, p, maxmem=0, dklen=64)

The function provides scrypt password-based key derivation function as defined in RFC 7914.

password and salt must be bytes-like objects. Applications and libraries should limit password to a sensible length (e.g. 1024). salt should be about 16 or more bytes from a proper source, e.g. os.urandom().

n is the CPU/Memory cost factor, r the block size, p parallelization factor and maxmem limits memory (OpenSSL 1.1.0 defaults to 32 MiB). dklen is the length of the derived key.

我计算出n必须是2的幂,并且至少是2

除此之外,我感到有点孤独。今天hashlib.scrypt(b"foo", salt=b"bar", n=2, r=1, p=1)会被认为是安全的吗?我如何判断采用哪些参数


Tags: andthetokeybytesfunctionpasswordbe