Type Stubs for Passlib

1.7.7.20260211 · maintenance · verified Sat Apr 11

types-passlib is a type stub package providing static type annotations for the 'passlib' library. It allows type checkers like Mypy and Pyright to analyze code that uses passlib. This package specifically targets passlib version 1.7.*. As of its latest release (1.7.7.20260211), the package is unmaintained, and any fixes or updates to the type stubs should be contributed directly to the `typeshed` project on GitHub. The upstream `passlib` library itself has maintenance concerns.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the core functionality of the `passlib` library for which `types-passlib` provides type hints: hashing and verifying a password using `CryptContext` with the bcrypt scheme.

from passlib.context import CryptContext
import os

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

def hash_password(password: str) -> str:
    return pwd_context.hash(password)

def verify_password(password: str, hashed_password: str) -> bool:
    return pwd_context.verify(password, hashed_password)

# Example usage
plain_password = os.environ.get('TEST_PASSWORD', 'mysecretpassword')
hashed = hash_password(plain_password)
print(f"Hashed password: {hashed}")

is_valid = verify_password(plain_password, hashed)
print(f"Password valid: {is_valid}")

is_invalid = verify_password('wrongpassword', hashed)
print(f"Wrong password valid: {is_invalid}")

view raw JSON →