Vulnerabilities | |||||
---|---|---|---|---|---|
Version | Suggest | Low | Medium | High | Critical |
0.17.0 | 0 | 0 | 0 | 0 | 0 |
0.16.0 | 0 | 0 | 0 | 0 | 0 |
0.15.1 | 0 | 0 | 0 | 0 | 0 |
0.15.0 | 0 | 0 | 0 | 0 | 0 |
0.14.0 | 0 | 0 | 0 | 0 | 0 |
0.13.0 | 0 | 0 | 0 | 0 | 0 |
0.12.1 | 0 | 0 | 0 | 0 | 0 |
0.12.0 | 0 | 0 | 0 | 0 | 0 |
0.11.0 | 0 | 0 | 0 | 0 | 0 |
0.10.1 | 0 | 0 | 0 | 0 | 0 |
0.10.0 | 0 | 0 | 0 | 0 | 0 |
0.9.0 | 0 | 0 | 0 | 0 | 0 |
0.8.2 | 0 | 0 | 0 | 0 | 0 |
0.8.1 | 0 | 0 | 0 | 0 | 0 |
0.8.0 | 0 | 0 | 0 | 0 | 0 |
0.7.0 | 0 | 0 | 0 | 0 | 0 |
0.6.3 | 0 | 0 | 0 | 0 | 0 |
0.6.2 | 0 | 0 | 0 | 0 | 0 |
0.6.1 | 0 | 0 | 0 | 0 | 0 |
0.6.0 | 0 | 0 | 0 | 0 | 0 |
0.5.0 | 0 | 0 | 0 | 0 | 0 |
0.4.0 | 0 | 0 | 0 | 0 | 0 |
0.3.0 | 0 | 0 | 0 | 0 | 0 |
0.2.2 | 0 | 0 | 0 | 0 | 0 |
0.2.1 | 0 | 0 | 0 | 0 | 0 |
0.2.0 | 0 | 0 | 0 | 0 | 0 |
0.1.6 | 0 | 0 | 0 | 0 | 0 |
0.1.5 | 0 | 0 | 0 | 0 | 0 |
0.1.4 | 0 | 0 | 0 | 0 | 0 |
0.1.3 | 0 | 0 | 0 | 0 | 0 |
0.1.2 | 0 | 0 | 0 | 0 | 0 |
0.1.1 | 0 | 0 | 0 | 0 | 0 |
0.1.0 | 0 | 0 | 0 | 0 | 0 |
0.17.0 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
MIT - MIT LicenseAdd the following to Cargo.toml:
bcrypt = "0.17"
The minimum Rust version is 1.63.0.
The crate makes 3 things public: DEFAULT_COST
, hash
, verify
.
extern crate bcrypt;
use bcrypt::{DEFAULT_COST, hash, verify};
let hashed = hash("hunter2", DEFAULT_COST)?;
let valid = verify("hunter2", &hashed)?;
The cost needs to be an integer between 4 and 31 (see benchmarks to have an idea of the speed for each), the DEFAULT_COST
is 12.
Most if not all bcrypt implementation truncates the password after 72 bytes. In specific use cases this can break 2nd pre-image resistance.
One can enforce the 72-bytes limit on input by using non_truncating_hash
, non_truncating_hash_with_result
, non_truncating_hash_with_salt
, and non_truncating_verify
.
The non_truncating_*
functions behave identically to their truncating counterparts unless the input is longer than 72 bytes, in which case they will return BcryptError::Truncation
.
If you are generating hashes from other libraries/languages, do not use the non_truncating_verify
function.
bcrypt
crate supports no_std
platforms. When alloc
feature is enabled,
all crate functionality is available. When alloc
is not enabled only the
raw bcrypt()
function is usable.
Speed depends on the cost used: the highest the slowest. Here are some benchmarks on a 2019 Macbook Pro to give you some ideas on the cost/speed ratio. Note that I don't go above 14 as it takes too long.
test bench_cost_10 ... bench: 51,474,665 ns/iter (+/- 16,006,581)
test bench_cost_14 ... bench: 839,109,086 ns/iter (+/- 274,507,463)
test bench_cost_4 ... bench: 795,814 ns/iter (+/- 42,838)
test bench_cost_default ... bench: 195,344,338 ns/iter (+/- 8,329,675)
This gist for the hash splitting and the null termination.
While bcrypt works well as an algorithm, using something like Argon2 is recommended for new projects.
js
featureenon_truncating_*
functionsalloc
feature that can be disabled.subtle
crate for constant time comparison, update base64 and bump to 2021 edition2x
std
featurehash_with_salt
function and make Version::format_for_version
publicbcrypt
function + edition 2018?
and handle more errors