keystone.common.password_hashers.pbkdf2 模块

class keystone.common.password_hashers.pbkdf2.Sha512[source]

基类: PasswordHasher

用于 PBKDF2 Sha512 密码哈希的 passlib 过渡类

static hash(password: bytes, salt_size: int = 16, rounds: int = 25000) str[source]

生成带有 ident 和参数的密码哈希字符串

https://cryptography.io/en/stable/hazmat/primitives/key-derivation-functions/#pbkdf2

参数:
  • password (bytes) – 要哈希的密码。

  • salt (bytes) – 盐。

  • iterations (int) – 迭代次数

返回值:

格式为 $pbkdf2-sha512$ln=logN,r=R,p=P$salt$checksum 的字符串

hash_algo = <cryptography.hazmat.primitives.hashes.SHA512 对象>
ident:> str = '$pbkdf2-sha512$'
name:> str = 'pbkdf2_sha512'
static verify(password:> bytes, hashed:> str) bool[source]

验证哈希密码是否等于 hashed

参数:
  • password (bytes) – 要验证的密码

  • hashed (string) – 哈希密码。用于提取哈希参数

返回值:

布尔值,表示使用相同的参数哈希密码是否与哈希值匹配