# keystone.common.password_hashers.bcrypt module

class keystone.common.password_hashers.bcrypt.Bcrypt

  Bases: `PasswordHasher`

  passlib transition class for implementing bcrypt password hashing

  static hash(password: bytes, rounds: int = 12, **kwargs) → str

    Generate password hash string with ident and params

    https://pypi.org/project/bcrypt/

    Parameters:

      - password (bytes) – Password to be hashed.

      - round (int) – Count of rounds.

    Returns:

      String in format $2b${rounds}${salt}{digest}

  ident_values: set[str] = {'$2$', '$2a$', '$2b$', '$2x$', '$2y$'}
  name: str = 'bcrypt'
  static verify(password: bytes, hashed: str) → bool

    Verify hashing password would be equal to the hashed value

    Parameters:

      - password (bytes) – Password to verify

      - hashed (string) – Hashed password. Used to extract hashing parameters

    Returns:

      boolean whether hashing password with the same parameters would match hashed value

class keystone.common.password_hashers.bcrypt.Bcrypt_sha256

  Bases: `PasswordHasher`

  passlib transition class for bcrypt_sha256 password hashing

  static hash(password: bytes, rounds: int = 12, **kwargs) → str

    Generate password hash string with ident and params

    https://pypi.org/project/bcrypt/

    Parameters:

      - password (bytes) – Password to be hashed.

      - round (int) – Count of rounds.

    Returns:

      String in format $bcrypt-sha256$r={rounds},t={ident},v={version}${salt}${digest}

  ident_values: set[str] = {'$2a$', '$2b$'}
  name: str = 'bcrypt_sha256'
  prefix: str = '$bcrypt-sha256$'
  static verify(password: bytes, hashed: str) → bool

    Verify hashing password would be equal to the hashed value

    Parameters:

      - password (bytes) – Password to verify

      - hashed (string) – Hashed password. Used to extract hashing parameters

    Returns:

      boolean whether hashing password with the same parameters would match hashed value

this page last updated: 2026-08-17 12:45:24

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug