bcryptbenchmark

command module
v0.0.0-...-2e89dbf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 10 Imported by: 0

README

Bcrypt Cost Benchmark Utility

About

This utility benchmarks the performance of the bcrypt password hashing algorithm at various cost levels. It helps you determine the optimal bcrypt cost setting for your environment by measuring the time required to hash passwords at different cost factors. The tool provides statistical analysis (mean, standard deviation, percentiles) for each cost level, making it easier to balance security and performance for your application.

Install

go install github.com/eldad/bcryptbenchmark@latest

How to Compile from Source

You need Go installed on your system.

go build -o bcrypt-benchmark ./cmd/benchmark

This will produce a bcrypt-benchmark executable in your current directory.

Cross compiling for arm64

If you need to cross-compiles the utility for the ARM64 architecture on Linux systems from a e.g. x86, use the following:

GOOS=linux GOARCH=arm64 go build -o bcryptbenchmark.arm64

Run the benchmark tool from your terminal:

./bcrypt-benchmark [options]

Example:

./bcrypt-benchmark -start 10 -end 14 -iterations 5 -generate 16

This runs the benchmark for bcrypt costs 10 through 14, using a randomly generated 16-character password, with 5 iterations per cost level.

Command Options

  • -start <int>
    • Starting bcrypt cost value (default: 10, minimum: 4)
  • -end <int>
    • Ending bcrypt cost value (default: 16, maximum: 31)
  • -password <string>
    • Password to hash (default: "correct-horse-battery-staple")
  • -generate <int>
    • Generate a random password of the given length (overrides -password if set)
  • -iterations <int>
    • Number of iterations per cost level (default: 3, minimum: 1)

Output

The tool prints a table of results for each cost level, including:

  • Mean hashing time
  • Standard deviation
  • 25th, 75th, 95th, and 99th percentiles

It also provides a recommendation for each cost level based on the measured mean time.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL