Skip to main content

CLI for benchmarking bcrypt cost factors on local hardware.

Project description

bcrypt-speed-tests

Small CLI for benchmarking bcrypt cost factors (rounds) so you can pick a sensible value on your target hardware.

What it does

  • Hashes a fixed password multiple times per cost factor.
  • Reports average time per cost in milliseconds.
  • Runs locally on the same machine your app will use.

Requirements

  • Python 3.9+
  • bcrypt (installed via project dependencies)

Install & Run from PyPI

Install uv first: https://docs.astral.sh/uv/

Preferred install with uv as a global tool:

uv tool install bcrypt-speed-tests

Run directly without installing:

uvx bcrypt-speed-tests

Add it to an existing project as a development dependency:

uv add bcrypt_speed_tests

Alternative installs:

pipx install bcrypt-speed-tests
pip install bcrypt-speed-tests

Install from repo

Clone and install locally:

git clone https://github.com/seapagan/bcrypt-speed-tests.git
cd bcrypt-speed-tests
uv sync

uv sync creates a local .venv by default.

Activate the virtual environment

source .venv/bin/activate

Deactivate when done:

deactivate

Windows (PowerShell):

.venv\Scripts\Activate.ps1

Or with pip:

pip install -e .

Run

bcrypt-speed-tests

CLI options

Available options:

Usage: bcrypt-speed-tests [OPTIONS] COMMAND [ARGS]...

Run the benchmark and print a timing table.

Options:
  --iterations  -i  INTEGER RANGE [x>=1]      Hashes to run per cost factor.
                                              [default: 3]
  --cost        -c  INTEGER RANGE [4<=x<=31]  Cost factor(s)/rounds. Repeat to
                                              pass multiple values.
  --help                                     Show this message and exit.

Override defaults at runtime:

bcrypt-speed-tests --iterations 5 --cost 10 --cost 12 --cost 14

Tasks

Run via poethepoet:

poe ruff
poe mypy
poe format

Configure

Edit defaults in src/bcrypt_speed_tests/benchmark.py:

  • ITERATIONS: hashes per cost factor
  • COSTS: bcrypt rounds (cost factor) range
  • PASSWORD: fixed input

Example output

Iterations per cost: 3

Cost | Avg time (ms)
----------------------
  10 |        23.4
  11 |        46.8
  12 |        93.1
  13 |       185.7
  14 |       370.9

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bcrypt_speed_tests-0.2.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bcrypt_speed_tests-0.2.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file bcrypt_speed_tests-0.2.0.tar.gz.

File metadata

  • Download URL: bcrypt_speed_tests-0.2.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bcrypt_speed_tests-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0ded9df6e3e0fda199c135e31b4b5efe5856651225f35517d231a04ed679d423
MD5 7ff373bcedec311e56c041ef7600603c
BLAKE2b-256 944d64a77c51f66f92a08e6872fd7b2c5c1a29c3520a895cdb2c3c76ff9a7bb4

See more details on using hashes here.

File details

Details for the file bcrypt_speed_tests-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bcrypt_speed_tests-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bcrypt_speed_tests-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8351d94bc2c31b71d9bbd56e2787e0a34cb9803fdc9c3545b68b2b04e1b593b2
MD5 e373f81867248c051a06f991c0cce334
BLAKE2b-256 d2f134ba7b975ea62d14e2a5a866f15c3a55f0152b0ad7a9ef4e3e3d6d2598d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page