Low-level CFFI bindings for Argon2

25.1.0 · active · verified Sat Mar 28

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.

Warnings

Install

Imports

Quickstart

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.

from _argon2_cffi_bindings import ffi, lib

# This package is for low-level interaction with the Argon2 C library.
# For typical password hashing in applications, use 'argon2-cffi' instead.
# Example: Accessing a C function (minimal, not a full hashing example):

# Check if the Argon2 library version can be retrieved
try:
    version_major = ffi.new('unsigned int *')
    version_minor = ffi.new('unsigned int *')
    lib.argon2_get_version(version_major, version_minor)
    print(f'Argon2 C library version: {version_major[0]}.{version_minor[0]}')
except AttributeError:
    print("Could not access argon2_get_version, direct CFFI usage may vary or be unavailable.")
except Exception as e:
    print(f"An error occurred during CFFI interaction: {e}")

# A more typical usage for most Python applications would be:
# from argon2 import PasswordHasher
# ph = PasswordHasher()
# hashed_password = ph.hash('mysecretpassword')

view raw JSON →