Recently, while writing a registration system for my backend project, I decided to use argon2 to hash passwords. And when I ran test requests on my backend, I was a bit surprised to see that it took me 600ms to hash through argon2. Then my friend ran argon2 hashing on his PC and the identical hashing took 25ms. From this I realized that my processor was crap, but still I wanted to make a CLI benchmark tool based on hash functions.
| Algorithm | Parameters |
|---|---|
| Argon2idFast | m=64MB, t=2, p=1 |
| Argon2idSecure | m=256MB, t=4, p=2 |
| Argon2i | m=128MB, t=3, p=1 |
| Argon2d | m=128MB, t=3, p=1 |
| Bcrypt | cost=10 |
| Bcrypt | cost=12 |
| Bcrypt | cost=14 |
| CPU | Argon2idFast | Argon2idSecure | Argon2i | Argon2d | Bcrypt10 | Bcrypt12 | Bcrypt14 |
|---|---|---|---|---|---|---|---|
| Intel Xeon E5-2650v4 @ 2.20GHz | 119ms | 950ms | 359ms | 350ms | 84ms | 341ms | 1398ms |
| Intel(R) Core(TM) Ultra 5 125H @ 2Ghz | 60ms | 513ms | 183ms | 182ms | 50ms | 205ms | 844ms |
| AMD Ryzen 5950X @ 3.9Ghz | 61ms | 477ms | 180ms | 179ms | 49ms | 195ms | 792ms |
| AMD Ryzen 5 2600 @ 3.4Ghz | 109ms | 911ms | 337ms | 342ms | 59ms | 232ms | 931ms |
| AMD Ryzen 5 5600H @ 3.8Ghz | 86ms | 632ms | 253ms | 251ms | 50ms | 203ms | 812ms |
| AMD Ryzen AI 9 HX 370 | 45ms | 436ms | 149ms | 145ms | 42ms | 172ms | 686ms |
Note
You must have Rust installed on your computer.
git clone https://github.com/smokingplaya/hash-cpu-bench
cd hash-cpu-bench
cargo build --releaseTip
The executable binary will be placed in ./target/release/hash-cpu-bench(.exe in Windows)
You can use the CLI interactively to hash strings on-the-fly and see the results instantly:
hash-cpu-bench- Select a hashing preset interactively:
Choose hashing preset (Argon2idFast, Argon2idSecure, Argon2i, Argon2d, Bcrypt10, Bcrypt12, Bcrypt14)
preset> Argon2idFast
- Hash any input by typing it:
> mypassword123
Argon2idFast: $argon2id$v=19$m=65536,t=2,p=1$... (659ms)
- Change the hashing preset at any time:
> preset Bcrypt12
Preset changed to Bcrypt12
- Exit the REPL:
> exit
Run a full benchmark of all supported hash algorithms:
hash-cpu-bench --benchmarkBy default, the benchmark will perform 15 iterations per algorithm and save results to ./bench_<timestamp>.json
--alg <ALGORITHM>- Run benchmark only for the specified algorithm (e.g.,Argon2idFast,Argon2i,Bcrypt10).
hash-cpu-bench --benchmark --alg Argon2idFast--repeats <N>- Set the number of iterations per algorithm (default:15).
hash-cpu-bench --benchmark --repeats 20Contributions are welcome! You can help by:
- Adding new hashing algorithms or presets.
- Improving benchmark accuracy and reporting.
- Enhancing the CLI user experience.
- Fixing bugs or improving documentation.
To contribute, fork the repository, make your changes, and submit a pull request. Please make sure your code follows the existing style.