{"library":"scrypt","title":"Python Scrypt Bindings","description":"The `scrypt` library provides Python bindings for the scrypt key derivation function, which is designed to make brute-force attacks on password hashes more difficult by requiring more memory and CPU. It's commonly used for securely hashing passwords. The current version is 0.9.4, with minor releases occurring periodically to address bug fixes and build improvements.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install scrypt"],"cli":null},"imports":["import scrypt","from scrypt import hash","from scrypt import verify"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import scrypt\nimport os\n\n# --- Parameters for scrypt (N, r, p) ---\n# N: CPU/Memory cost parameter (must be a power of 2, e.g., 2**14 = 16384)\n#    Higher N means more work, increasing security against brute-force attacks.\n# r: Block size parameter\n# p: Parallelization parameter\n# Choosing these values appropriately is critical for security and performance.\n# For production, recommended values are often N=2**14 to 2**20, r=8, p=1.\n# Values too high can cause excessive memory/CPU usage, potentially leading to DoS.\nN = 16384  # 2**14\nr = 8\np = 1\n\npassword = b\"my_super_secret_password\"\n# Generate a cryptographically secure random salt (at least 16 bytes)\nsalt = os.urandom(16)\n\ntry:\n    # 1. Hash the password\n    # The hash function returns bytes\n    hashed_password_bytes = scrypt.hash(password, salt, N, r, p)\n    print(f\"Scrypt hash (hex): {hashed_password_bytes.hex()}\")\n\n    # 2. Verify the password\n    # For verification, the original password, salt, and parameters (N, r, p)\n    # used during hashing must be provided.\n    is_valid = scrypt.verify(password, hashed_password_bytes, salt, N, r, p)\n    print(f\"Password verification successful: {is_valid}\")\n\n    # Example of a wrong password\n    wrong_password = b\"wrong_password\"\n    try:\n        scrypt.verify(wrong_password, hashed_password_bytes, salt, N, r, p)\n        print(\"Verification with wrong password succeeded (ERROR!)\")\n    except scrypt.error:\n        print(\"Verification with wrong password failed (EXPECTED)\")\n\nexcept scrypt.error as e:\n    print(f\"An scrypt error occurred: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n\n# In a real application, you would store the salt and N, r, p parameters\n# alongside the hash (e.g., as part of a standard scrypt format string like $s0$...)\n# The 'scrypt' library does not provide this format string generation directly;\n# you need to implement that logic yourself or use a higher-level library.","lang":"python","description":"This quickstart demonstrates how to hash a password using `scrypt.hash()` and verify it with `scrypt.verify()`. It highlights the importance of `N`, `r`, and `p` parameters and the use of cryptographically secure random salts. Inputs (password and salt) must be `bytes`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.9.4","pypi_latest":"0.9.4","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.6,"avg_import_s":0.01,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.01,"mem_mb":0.4,"disk_size":"23.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.6,"import_time_s":0.01,"mem_mb":1.1,"disk_size":"22M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.02,"mem_mb":0.6,"disk_size":"24.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.6,"import_time_s":0.02,"mem_mb":1.1,"disk_size":"24M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.01,"mem_mb":0.3,"disk_size":"16.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.5,"import_time_s":0.02,"mem_mb":1.2,"disk_size":"15M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.01,"mem_mb":0.8,"disk_size":"16.5M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.5,"import_time_s":0.02,"mem_mb":1.3,"disk_size":"15M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.01,"mem_mb":0.7,"disk_size":"22.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"scrypt","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.9,"import_time_s":0.02,"mem_mb":1.1,"disk_size":"21M"}]}}