简体   繁体   English

python 模块 argon2-cffi 使用了 Argon2 的什么“味道”?

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

Argon2 v1.3 is the algorithm used by python module argon2-cffi . Argon2 v1.3 是 python 模块argon2-cffi使用的算法。

In the documentation they state the following:文档中他们 state 如下:

"argon2-cffi implements Argon2 version 1.3, as described in in: Argon2: the memory-hard function for password hashing and other applications ." “argon2-cffi 实现 Argon2 版本 1.3,如: Argon2:用于密码散列和其他应用程序的内存硬 function 中所述。”

Yet this document does not specify the actual use of any "flavour" (i/d/id), it just explains the differences.然而,本文档没有具体说明任何“风味”(i/d/id)的实际用途,它只是解释了不同之处。

What "flavour" is used by argon2-cffi by default? argon2-cffi默认使用什么“风味”? Is there a way to specify the "flavour" you want to use?有没有办法指定您要使用的“风味”?

Judging from the return value of the hash function in class PasswordHasher from argon2-cffi , it appears it can be concluded that the hybrid "flavour" is used by default.argon2-cffi的 class PasswordHasherhash function 的返回值来看,似乎可以断定,hybrid "fl"默认使用

from argon2 import PasswordHasher

PasswordHasher().hash("foo")

Returns:回报:

"$argon2id$v=19$m=65536,t=3,p=4$xIu1KPUI7Ofe6HxYhmbNiA$6q7HjVOe6933Ogaw0f7pLodCdBgJsST8JAszTkv4Jh4"

This is confirmed by the comment in said class: class 中的评论证实了这一点:

Uses Argon2\ **id** by default and always uses a random salt_ for hashing.默认使用 Argon2\ **id** 并始终使用随机 salt_ 进行散列。 But it can verify any type of Argon2 as long as the hash is correctly encoded.但只要 hash 编码正确,它就可以验证任何类型的Argon2

Changing the "flavour" used by the module is done by assigning the variable type of class PasswordHasher to a Type class defined in like so:通过将 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

Each of these Type variables reference a corresponding argon2 library, shown in comments.这些Type变量中的每一个都引用了相应的 argon2 库,如注释中所示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM