{"id":609,"library":"argon2-cffi-bindings","title":"Low-level CFFI bindings for Argon2","description":"argon2-cffi-bindings provides low-level CFFI bindings to the official implementation of the Argon2 password hashing algorithm. It is primarily intended to be used as a backend dependency for high-level Python packages like `argon2-cffi`, and is not recommended for direct application password hashing. The library is actively maintained and currently at version 25.1.0, with regular releases aligning with updates to the underlying Argon2 C library and Python ecosystem changes.","status":"active","version":"25.1.0","language":"python","source_language":"en","source_url":"https://github.com/hynek/argon2-cffi-bindings","tags":["security","cryptography","password hashing","cffi","bindings","low-level"],"install":[{"cmd":"pip install argon2-cffi-bindings","lang":"bash","label":"Standard installation"}],"dependencies":[{"reason":"Required for the CFFI bindings to the Argon2 C library. Version 2.0 or newer is necessary for free-threading support on Python 3.14+.","package":"cffi","optional":false},{"reason":"The underlying Argon2 C library. A vendored copy is used by default, but a system-wide installation can be used with specific environment variables.","package":"libargon2-1","optional":false}],"imports":[{"note":"This package is intended as an implementation detail. Its public API is deliberately placed in a private module `_argon2_cffi_bindings` to discourage direct use by end-users. Accessing `ffi` and `lib` directly is for advanced scenarios or other libraries.","wrong":"from argon2_cffi_bindings import ffi, lib","symbol":"ffi, lib","correct":"from _argon2_cffi_bindings import ffi, lib"}],"quickstart":{"code":"from _argon2_cffi_bindings import ffi, lib\n\n# This package is for low-level interaction with the Argon2 C library.\n# For typical password hashing in applications, use 'argon2-cffi' instead.\n# Example: Accessing a C function (minimal, not a full hashing example):\n\n# Check if the Argon2 library version can be retrieved\ntry:\n    version_major = ffi.new('unsigned int *')\n    version_minor = ffi.new('unsigned int *')\n    lib.argon2_get_version(version_major, version_minor)\n    print(f'Argon2 C library version: {version_major[0]}.{version_minor[0]}')\nexcept AttributeError:\n    print(\"Could not access argon2_get_version, direct CFFI usage may vary or be unavailable.\")\nexcept Exception as e:\n    print(f\"An error occurred during CFFI interaction: {e}\")\n\n# A more typical usage for most Python applications would be:\n# from argon2 import PasswordHasher\n# ph = PasswordHasher()\n# hashed_password = ph.hash('mysecretpassword')","lang":"python","description":"This quickstart demonstrates how to access the `ffi` and `lib` objects from the private `_argon2_cffi_bindings` module. It emphasizes that this package is for low-level CFFI interaction, and recommends `argon2-cffi` for high-level application password hashing. The example attempts to retrieve the Argon2 C library version directly via the bindings."},"warnings":[{"fix":"Install and use `argon2-cffi` for password hashing: `pip install argon2-cffi`.","message":"This library is NOT intended for direct use in applications for password hashing. It provides low-level CFFI bindings. For application-level password hashing, the `argon2-cffi` package (which uses these bindings) is the recommended and high-level solution.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `from _argon2_cffi_bindings import ffi, lib`.","message":"Direct imports for the `ffi` and `lib` objects are from the private module `_argon2_cffi_bindings`, not `argon2_cffi_bindings`. Attempting to import from the top-level package name will result in an `ImportError` or `AttributeError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When installing `argon2-cffi` with `uv` for Python 3.14+: `uv pip install --prerelease=allow argon2-cffi`. Ensure your build environment supports CFFI 2.0.","message":"For Python 3.14+ and enabling free-threading, a prerelease version of CFFI (2.0 or newer) is required. When using `uv` for installation, a special flag is needed for `argon2-cffi` (which pulls in these bindings).","severity":"gotcha","affected_versions":"25.1.0 onwards (specifically for Python 3.14+ free-threading)"},{"fix":"Set `ARGON2_CFFI_USE_SSE2=1` to force SSE2, or `ARGON2_CFFI_USE_SSE2=0` to disable it, before installation.","message":"The build process automatically detects whether to use SSE2-optimized code. This detection can be overridden for cross-compiling or specific build environments using an environment variable.","severity":"gotcha","affected_versions":"20.1.0 onwards"},{"fix":"Upgrade to Python 3.9 or newer. Ensure your project's `python_requires` aligns with supported versions.","message":"Older versions of `argon2-cffi` (from which these bindings were extracted) have dropped support for Python 2.7 (version 20.1.0 was last) and Python 3.5 (version 21.1.0 was last). The `argon2-cffi-bindings` package itself requires Python >=3.9.","severity":"deprecated","affected_versions":"<=21.1.0 (for `argon2-cffi` pre-extraction, affecting overall ecosystem)"}],"env_vars":null,"last_verified":"2026-05-12T16:40:19.117Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install the module using pip: 'pip install argon2-cffi-bindings'.","cause":"The 'argon2_cffi_bindings' module is not installed in the Python environment.","error":"ModuleNotFoundError: No module named 'argon2_cffi_bindings'"},{"fix":"Ensure the wheel file matches your Python version and architecture, or download the correct wheel file for offline installation.","cause":"Attempting to install 'argon2-cffi-bindings' offline with an incompatible wheel file.","error":"ERROR: Could not find a version that satisfies the requirement argon2-cffi-bindings (from versions: none)\nERROR: No matching distribution found for argon2-cffi-bindings"},{"fix":"Install the necessary build tools and 'libffi' development package for your operating system.","cause":"The installation process requires a C compiler and the 'libffi' development package, which are missing.","error":"Command 'python setup.py egg_info' failed with error code 1 in /tmp/pip-build-*/argon2-cffi-bindings/"},{"fix":"Ensure all source files are present and accessible, or use a pre-built wheel to avoid building from source.","cause":"The source files for Argon2 are missing during the build process.","error":"x86_64-linux-gnu-gcc: error: extras/libargon2/src/argon2.c: No such file or directory"},{"fix":"Ensure `argon2-cffi` is correctly installed, as it automatically pulls in and builds `argon2-cffi-bindings`. It's recommended to update `pip`, `setuptools`, and `cffi` before installation: `python -m pip install -U pip setuptools cffi` followed by `pip install argon2-cffi`. For direct low-level usage (discouraged for most applications), ensure `argon2-cffi-bindings` is installed correctly.","cause":"This error occurs when the underlying CFFI bindings, which are a private implementation detail of `argon2-cffi`, cannot be found. This often indicates an incomplete or failed installation of `argon2-cffi` or `argon2-cffi-bindings` itself, or an environment issue (e.g., in a Docker container) preventing the module from being located.","error":"ModuleNotFoundError: No module named '_argon2_cffi_bindings'"}],"ecosystem":"pypi","meta_description":null,"install_score":80,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"25.1.0","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19.4M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19.4M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.9,"import_time_s":0,"mem_mb":0,"disk_size":"20M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"20M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"21.6M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"21.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.9,"import_time_s":0,"mem_mb":0,"disk_size":"22M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"22M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"13.4M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"13.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0,"mem_mb":0,"disk_size":"14M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"14M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0.2,"disk_size":"13.1M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0.2,"disk_size":"13.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0,"mem_mb":0,"disk_size":"14M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"14M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19.7M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.3,"import_time_s":0,"mem_mb":0,"disk_size":"20M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"20M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}