python 模块 argon2-cffi 使用了 Argon2 的 "flavour" 什么?

What "flavour" of Argon2 is used by python module argon2-cffi?

Argon2 v1.3 是 python 模块 argon2-cffi 使用的算法。

documentation 中,他们声明如下:

"argon2-cffi implements Argon2 version 1.3, as described in in: Argon2: the memory-hard function for password hashing and other applications."

然而这份文件并没有具体说明任何“味道”的实际用途(i/d/id),它只是解释了差异。

argon2-cffi 默认使用什么“风味”?有没有办法指定您要使用的“风味”?

从 class PasswordHasherhash 函数的 return 值来看 argon2-cffi,似乎可以得出结论,混合“默认使用 flavor"。

from argon2 import PasswordHasher

PasswordHasher().hash("foo")

Returns:

"$argon2id$v=19$m=65536,t=3,p=4$xIu1KPUI7Ofe6HxYhmbNiAq7HjVOe6933Ogaw0f7pLodCdBgJsST8JAszTkv4Jh4"

class中的评论证实了这一点:

Uses Argon2\ **id** by default and always uses a random salt_ for hashing. But it can verify any type of Argon2 as long as the hash is correctly encoded.

通过将 class PasswordHasher 的变量 type 分配给定义在中的 Type class 来更改模块使用的“风味”像这样:

from argon2 import PasswordHasher, Type
PasswordHasher(type=Type.I).hash("foo")  # lib.Argon2_i
PasswordHasher(type=Type.D).hash("foo")  # lib.Argon2_d
PasswordHasher(type=Type.ID).hash("foo") # lib.Argon2_id

这些 Type 变量中的每一个都引用相应的 argon2 库,如注释中所示。